Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/uacaps/PageMenu into obje…
Browse files Browse the repository at this point in the history
…ctive_c
  • Loading branch information
jinSasaki committed Jun 6, 2015
1 parent a879665 commit 2080451
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 129 deletions.
69 changes: 4 additions & 65 deletions Classes/CAPSPageMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public enum CAPSPageMenuOption {
case MenuMargin(CGFloat)
case MenuHeight(CGFloat)
case SelectedMenuItemLabelColor(UIColor)
case UnselectedMenuLabelColor(UIColor)
case UnselectedMenuItemLabelColor(UIColor)
case UseMenuLikeSegmentedControl(Bool)
case MenuItemSeparatorRoundEdges(Bool)
case MenuItemFont(UIFont)
Expand Down Expand Up @@ -163,67 +163,6 @@ public class CAPSPageMenu: UIViewController, UIScrollViewDelegate, UIGestureReco
controllerArray = viewControllers

self.view.frame = frame

if let options = options {
for key in options.keys {
if key == "selectionIndicatorHeight" {
selectionIndicatorHeight = options[key] as! CGFloat
} else if key == "menuItemSeparatorWidth" {
menuItemSeparatorWidth = options[key] as! CGFloat
} else if key == "scrollMenuBackgroundColor" {
scrollMenuBackgroundColor = options[key] as! UIColor
} else if key == "viewBackgroundColor" {
viewBackgroundColor = options[key] as! UIColor
} else if key == "bottomMenuHairlineColor" {
bottomMenuHairlineColor = options[key] as! UIColor
} else if key == "selectionIndicatorColor" {
selectionIndicatorColor = options[key] as! UIColor
} else if key == "menuItemSeparatorColor" {
menuItemSeparatorColor = options[key] as! UIColor
} else if key == "menuMargin" {
menuMargin = options[key] as! CGFloat
} else if key == "menuHeight" {
menuHeight = options[key] as! CGFloat
} else if key == "selectedMenuItemLabelColor" {
selectedMenuItemLabelColor = options[key] as! UIColor
} else if key == "unselectedMenuItemLabelColor" {
unselectedMenuItemLabelColor = options[key] as! UIColor
} else if key == "useMenuLikeSegmentedControl" {
useMenuLikeSegmentedControl = options[key] as! Bool
} else if key == "menuItemSeparatorRoundEdges" {
menuItemSeparatorRoundEdges = options[key] as! Bool
} else if key == "menuItemFont" {
menuItemFont = options[key] as! UIFont
} else if key == "menuItemSeparatorPercentageHeight" {
menuItemSeparatorPercentageHeight = options[key] as! CGFloat
} else if key == "menuItemWidth" {
menuItemWidth = options[key] as! CGFloat
} else if key == "enableHorizontalBounce" {
enableHorizontalBounce = options[key] as! Bool
} else if key == "addBottomMenuHairline" {
addBottomMenuHairline = options[key] as! Bool
} else if key == "menuItemWidthBasedOnTitleTextWidth" {
menuItemWidthBasedOnTitleTextWidth = options[key] as! Bool
} else if key == "scrollAnimationDurationOnMenuItemTap" {
scrollAnimationDurationOnMenuItemTap = options[key] as! Int
} else if key == "centerMenuItems" {
centerMenuItems = options[key] as! Bool
} else if key == "hideTopMenuBar" {
hideTopMenuBar = options[key] as! Bool
}
}

if hideTopMenuBar {
addBottomMenuHairline = false
menuHeight = 0.0
}
}

setUpUserInterface()

if menuScrollView.subviews.count == 0 {
configureUserInterface()
}
}

public convenience init(viewControllers: [UIViewController], frame: CGRect, pageMenuOptions: [CAPSPageMenuOption]?) {
Expand Down Expand Up @@ -252,7 +191,7 @@ public class CAPSPageMenu: UIViewController, UIScrollViewDelegate, UIGestureReco
menuHeight = value
case let .SelectedMenuItemLabelColor(value):
selectedMenuItemLabelColor = value
case let .UnselectedMenuLabelColor(value):
case let .UnselectedMenuItemLabelColor(value):
unselectedMenuItemLabelColor = value
case let .UseMenuLikeSegmentedControl(value):
useMenuLikeSegmentedControl = value
Expand Down Expand Up @@ -503,7 +442,7 @@ public class CAPSPageMenu: UIViewController, UIScrollViewDelegate, UIGestureReco
if !didLayoutSubviewsAfterRotation {
if scrollView.isEqual(controllerScrollView) {
if scrollView.contentOffset.x >= 0.0 && scrollView.contentOffset.x <= (CGFloat(controllerArray.count - 1) * self.view.frame.width) {
if (currentOrientationIsPortrait && self.interfaceOrientation.isPortrait) || (!currentOrientationIsPortrait && self.interfaceOrientation.isLandscape) {
if (currentOrientationIsPortrait && UIApplication.sharedApplication().statusBarOrientation.isPortrait) || (!currentOrientationIsPortrait && UIApplication.sharedApplication().statusBarOrientation.isLandscape) {
// Check if scroll direction changed
if !didTapMenuItemToScroll {
if didScrollAlready {
Expand Down Expand Up @@ -838,7 +777,7 @@ public class CAPSPageMenu: UIViewController, UIScrollViewDelegate, UIGestureReco
controllerScrollView.contentSize = CGSizeMake(self.view.frame.width * CGFloat(controllerArray.count), self.view.frame.height - menuHeight)

var oldCurrentOrientationIsPortrait : Bool = currentOrientationIsPortrait
currentOrientationIsPortrait = self.interfaceOrientation.isPortrait
currentOrientationIsPortrait = UIApplication.sharedApplication().statusBarOrientation.isPortrait

if (oldCurrentOrientationIsPortrait && UIDevice.currentDevice().orientation.isLandscape) || (!oldCurrentOrientationIsPortrait && UIDevice.currentDevice().orientation.isPortrait) {
didLayoutSubviewsAfterRotation = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ class ViewController: UIViewController {
controllerArray.append(controller4)

// Customize menu (Optional)
var parameters: [String: AnyObject] = ["scrollMenuBackgroundColor": UIColor(red: 30.0/255.0, green: 30.0/255.0, blue: 30.0/255.0, alpha: 1.0),
"viewBackgroundColor": UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0),
"selectionIndicatorColor": UIColor.orangeColor(),
"bottomMenuHairlineColor": UIColor(red: 70.0/255.0, green: 70.0/255.0, blue: 80.0/255.0, alpha: 1.0),
"menuItemFont": UIFont(name: "HelveticaNeue", size: 13.0)!,
"menuHeight": 40.0,
"menuItemWidth": 90.0,
"centerMenuItems": true]
var parameters: [CAPSPageMenuOption] = [
.ScrollMenuBackgroundColor(UIColor(red: 30.0/255.0, green: 30.0/255.0, blue: 30.0/255.0, alpha: 1.0)),
.ViewBackgroundColor(UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0)),
.SelectionIndicatorColor(UIColor.orangeColor()),
.BottomMenuHairlineColor(UIColor(red: 70.0/255.0, green: 70.0/255.0, blue: 80.0/255.0, alpha: 1.0)),
.MenuItemFont(UIFont(name: "HelveticaNeue", size: 13.0)!),
.MenuHeight(40.0),
.MenuItemWidth(90.0),
.CenterMenuItems(true)
]

// Initialize scroll menu
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), options: parameters)
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)

self.view.addSubview(pageMenu!.view)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TestViewController: UIViewController {
controllerArray.append(controller4)

// Initialize scroll menu
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 50.0, self.view.frame.width, 100), options: nil)
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 50.0, self.view.frame.width, 100), pageMenuOptions: nil)

println(self.view.frame.height)

Expand Down Expand Up @@ -70,7 +70,7 @@ class TestViewController: UIViewController {
controllerArray_1.append(controller4_1)

// Initialize scroll menu
pageMenu1 = CAPSPageMenu(viewControllers: controllerArray_1, frame: CGRectMake(0.0, 400.0, self.view.frame.width, 100.0), options: nil)
pageMenu1 = CAPSPageMenu(viewControllers: controllerArray_1, frame: CGRectMake(0.0, 400.0, self.view.frame.width, 100.0), pageMenuOptions: nil)

self.view.addSubview(pageMenu1!.view)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,20 @@ class ViewController: UIViewController {
controllerArray.append(controller4)

// Customize menu (Optional)
var parameters: [String: AnyObject] = ["scrollMenuBackgroundColor": UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0),
"viewBackgroundColor": UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0),
"selectionIndicatorColor": UIColor.orangeColor(),
"addBottomMenuHairline": false,
"menuItemFont": UIFont(name: "HelveticaNeue", size: 35.0)!,
"menuHeight": 50.0,
"selectionIndicatorHeight": 0.0,
"menuItemWidthBasedOnTitleTextWidth": true,
"selectedMenuItemLabelColor": UIColor.orangeColor()]
var parameters: [CAPSPageMenuOption] = [
.ScrollMenuBackgroundColor(UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0)),
.ViewBackgroundColor(UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0)),
.SelectionIndicatorColor(UIColor.orangeColor()),
.AddBottomMenuHairline(false),
.MenuItemFont(UIFont(name: "HelveticaNeue", size: 35.0)!),
.MenuHeight(50.0),
.SelectionIndicatorHeight(0.0),
.MenuItemWidthBasedOnTitleTextWidth(true),
.SelectedMenuItemLabelColor(UIColor.orangeColor())
]

// Initialize scroll menu
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), options: parameters)
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)

self.view.addSubview(pageMenu!.view)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,22 @@ class PageMenuOneViewController: UIViewController {
}

// Customize menu (Optional)
var parameters: [String: AnyObject] = ["scrollMenuBackgroundColor": UIColor.orangeColor(),
"viewBackgroundColor": UIColor.whiteColor(),
"selectionIndicatorColor": UIColor.whiteColor(),
"unselectedMenuItemLabelColor": UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 0.4),
"menuItemFont": UIFont(name: "HelveticaNeue", size: 35.0)!,
"menuHeight": 44.0,
"menuMargin": 20.0,
"selectionIndicatorHeight": 0.0,
"bottomMenuHairlineColor": UIColor.orangeColor(),
"menuItemWidthBasedOnTitleTextWidth": true,
"selectedMenuItemLabelColor": UIColor.whiteColor()]
var parameters: [CAPSPageMenuOption] = [
.ScrollMenuBackgroundColor(UIColor.orangeColor()),
.ViewBackgroundColor(UIColor.whiteColor()),
.SelectionIndicatorColor(UIColor.whiteColor()),
.UnselectedMenuItemLabelColor(UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 0.4)),
.MenuItemFont(UIFont(name: "HelveticaNeue", size: 35.0)!),
.MenuHeight(44.0),
.MenuMargin(20.0),
.SelectionIndicatorHeight(0.0),
.BottomMenuHairlineColor(UIColor.orangeColor()),
.MenuItemWidthBasedOnTitleTextWidth(true),
.SelectedMenuItemLabelColor(UIColor.whiteColor())
]

// Initialize scroll menu
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 60.0, self.view.frame.width, self.view.frame.height - 60.0), options: parameters)
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 60.0, self.view.frame.width, self.view.frame.height - 60.0), pageMenuOptions: parameters)

self.view.addSubview(pageMenu!.view)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ class PageMenuTwoViewController: UIViewController {
controllerArray.append(controller4)

// Customize menu (Optional)
var parameters: [String: AnyObject] = ["scrollMenuBackgroundColor": UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0),
"viewBackgroundColor": UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0),
"selectionIndicatorColor": UIColor.orangeColor(),
"addBottomMenuHairline": false,
"menuItemFont": UIFont(name: "HelveticaNeue", size: 35.0)!,
"menuHeight": 50.0,
"selectionIndicatorHeight": 0.0,
"menuItemWidthBasedOnTitleTextWidth": true,
"selectedMenuItemLabelColor": UIColor.orangeColor()]
var parameters: [CAPSPageMenuOption] = [
.ScrollMenuBackgroundColor(UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0)),
.ViewBackgroundColor(UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0)),
.SelectionIndicatorColor(UIColor.orangeColor()),
.AddBottomMenuHairline(false),
.MenuItemFont(UIFont(name: "HelveticaNeue", size: 35.0)!),
.MenuHeight(50.0),
.SelectionIndicatorHeight(0.0),
.MenuItemWidthBasedOnTitleTextWidth(true),
.SelectedMenuItemLabelColor(UIColor.orangeColor())
]

// Initialize scroll menu
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 60.0, self.view.frame.width, self.view.frame.height - 60.0), options: parameters)
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 60.0, self.view.frame.width, self.view.frame.height - 60.0), pageMenuOptions: parameters)

self.view.addSubview(pageMenu!.view)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,25 @@ class ViewController: UIViewController, CAPSPageMenuDelegate {
controllerArray.append(controller4)

// Customize menu (Optional)
var parameters: [String: AnyObject] = ["menuItemSeparatorWidth": 4.3,
"scrollMenuBackgroundColor": UIColor.whiteColor(),
"viewBackgroundColor": UIColor(red: 247.0/255.0, green: 247.0/255.0, blue: 247.0/255.0, alpha: 1.0),
"bottomMenuHairlineColor": UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 0.1),
"selectionIndicatorColor": UIColor(red: 18.0/255.0, green: 150.0/255.0, blue: 225.0/255.0, alpha: 1.0),
"menuMargin": 20.0,
"menuHeight": 40.0,
"selectedMenuItemLabelColor": UIColor(red: 18.0/255.0, green: 150.0/255.0, blue: 225.0/255.0, alpha: 1.0),
"unselectedMenuItemLabelColor": UIColor(red: 40.0/255.0, green: 40.0/255.0, blue: 40.0/255.0, alpha: 1.0),
"menuItemFont": UIFont(name: "HelveticaNeue-Medium", size: 14.0)!,
"useMenuLikeSegmentedControl": true,
"menuItemSeparatorRoundEdges": true,
"selectionIndicatorHeight": 2.0,
"menuItemSeparatorPercentageHeight": 0.1]
var parameters: [CAPSPageMenuOption] = [
.MenuItemSeparatorWidth(4.3),
.ScrollMenuBackgroundColor(UIColor.whiteColor()),
.ViewBackgroundColor(UIColor(red: 247.0/255.0, green: 247.0/255.0, blue: 247.0/255.0, alpha: 1.0)),
.BottomMenuHairlineColor(UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 0.1)),
.SelectionIndicatorColor(UIColor(red: 18.0/255.0, green: 150.0/255.0, blue: 225.0/255.0, alpha: 1.0)),
.MenuMargin(20.0),
.MenuHeight(40.0),
.SelectedMenuItemLabelColor(UIColor(red: 18.0/255.0, green: 150.0/255.0, blue: 225.0/255.0, alpha: 1.0)),
.UnselectedMenuItemLabelColor(UIColor(red: 40.0/255.0, green: 40.0/255.0, blue: 40.0/255.0, alpha: 1.0)),
.MenuItemFont(UIFont(name: "HelveticaNeue-Medium", size: 14.0)!),
.UseMenuLikeSegmentedControl(true),
.MenuItemSeparatorRoundEdges(true),
.SelectionIndicatorHeight(2.0),
.MenuItemSeparatorPercentageHeight(0.1)
]

// Initialize scroll menu
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), options: parameters)
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)

// Optional delegate
pageMenu!.delegate = self
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions PageMenu.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "PageMenu"
s.version = "1.2.3"
s.version = "1.2.7"
s.summary = "A paging menu controller built from other view controllers allowing the user to switch between any kind of view controller."
s.homepage = "https://github.com/uacaps/PageMenu"
s.license = { :type => 'UA', :file => 'LICENSE' }
s.author = { "uacaps" => "[email protected]" }
s.source = { :git => "https://github.com/uacaps/PageMenu.git", :tag => '1.2.3' }
s.source = { :git => "https://github.com/uacaps/PageMenu.git", :tag => '1.2.7' }
s.platform = :ios, '8.0'
s.source_files = 'Classes/*'
s.requires_arc = true
Expand Down
Loading

0 comments on commit 2080451

Please sign in to comment.