From 2ba28fe64e15316161cb724953babc220af6793e Mon Sep 17 00:00:00 2001 From: DuckDeck <3421902@qq.com> Date: Sat, 27 Feb 2016 13:18:22 +0800 Subject: [PATCH] Reset the table height --- GrandMenu.podspec | 4 ++-- GrandMenu/GrandMenu.swift | 10 ++++++---- GrandMenuDemo/GrandMenuDemo/ViewController.swift | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/GrandMenu.podspec b/GrandMenu.podspec index 859c2e2..7187fda 100644 --- a/GrandMenu.podspec +++ b/GrandMenu.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "GrandMenu" - s.version = "0.0.2" + s.version = "0.0.3" s.summary = "GrandMenu is a powerful and simple Menu" # This description is used to generate tags and improve search results. @@ -80,7 +80,7 @@ Pod::Spec.new do |s| # Supports git, hg, bzr, svn and HTTP. # - s.source = { :git => "https://github.com/DuckDeck/GrandMenu.git", :tag => "0.0.2" } + s.source = { :git => "https://github.com/DuckDeck/GrandMenu.git", :tag => "0.0.3" } # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # diff --git a/GrandMenu/GrandMenu.swift b/GrandMenu/GrandMenu.swift index 94298e0..b19f867 100644 --- a/GrandMenu/GrandMenu.swift +++ b/GrandMenu/GrandMenu.swift @@ -99,6 +99,7 @@ public class GrandMenu: UIView,GraneMenuItemDelegate { private var scrollView:UIScrollView? private var arrItems:[GrandMenuItem]? private var vSlider:UIView? + private var vBottomLine:UIView? private var selectedItem:GrandMenuItem?{ willSet{ selectedItem?.selected = false //这个警告可以无视 @@ -137,10 +138,11 @@ public class GrandMenu: UIView,GraneMenuItemDelegate { arrItemsTitle = titles setupItems() } - public func addBottomLine(bgColor:UIColor,height:Float){ - let line = UIView(frame: CGRect(x: CGFloat(0), y: CGRectGetMaxY(self.frame), width: UIScreen.mainScreen().bounds.width, height: CGFloat(height))) - line.backgroundColor = bgColor - self.superview?.addSubview(line) + public func addBottomLine(bgColor:UIColor,size:CGSize){ + vBottomLine = UIView(frame: CGRect(x: (self.frame.size.width - size.width) / 2, y: self.frame.size.height, width: size.width, height: size.height)) + vBottomLine?.backgroundColor = bgColor + addSubview(vBottomLine!) + self.frame = CGRect(x: self.frame.origin.x, y: self.frame.origin.y, width: self.frame.size.width, height: CGRectGetMaxY(vBottomLine!.frame)) } func setupItems(){ diff --git a/GrandMenuDemo/GrandMenuDemo/ViewController.swift b/GrandMenuDemo/GrandMenuDemo/ViewController.swift index 24c51ea..86e8dae 100644 --- a/GrandMenuDemo/GrandMenuDemo/ViewController.swift +++ b/GrandMenuDemo/GrandMenuDemo/ViewController.swift @@ -30,6 +30,8 @@ class ViewController: UIViewController { grandMenu?.sliderBarLeftRightOffset = 15 grandMenu?.itemSelectedFont = 16 view.addSubview(grandMenu!) + // grandMenu?.addBottomLine(UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 0.6), height: 5) + grandMenu?.addBottomLine(UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 0.6), size: CGSize(width: 200, height: 1)) arrControllers = [UIViewController]() let vc1 = Controller1() let vc2 = Controller2() @@ -41,7 +43,7 @@ class ViewController: UIViewController { arrControllers?.append(vc3) arrControllers?.append(vc4) arrControllers?.append(vc5) - grandMenuTable = GrandMenuTable(frame: CGRect(x: 0, y: 104, width: UIScreen.mainScreen().bounds.size.width, height: view.frame.size.height - 104), arrContent: arrControllers!) + grandMenuTable = GrandMenuTable(frame: CGRect(x: 0, y: CGRectGetMaxY(grandMenu!.frame), width: UIScreen.mainScreen().bounds.size.width, height: view.frame.size.height - 104), arrContent: arrControllers!) grandMenuTable?.scrollToIndex = scrollToIndex view.addSubview(grandMenuTable!) }