This library is inspired by PageMenu
See CHANGELOG for details
*** Swift 2.0 ***
Please use swift_2.0 branch if you want to try in Swift 2.0
- default page index to show as a first view
defaultPage: Int
- background color for menu view
backgroundColor: UIColor
- background color for selected menu item
selectedBackgroundColor: UIColor
- text color for menu item
textColor: UIColor
- text color for selected menu item
selectedTextColor: UIColor
- font for menu item text
font: UIFont
- menu position
menuPosition: MenuPosition
- height for menu view
menuHeight: CGFloat
- margin for each menu item
menuItemMargin: CGFloat
- duration for menu item view animation
animationDuration: NSTimeInterval
- menu display mode and scrolling mode
menuDisplayMode: MenuDisplayMode
public enum MenuDisplayMode {
case FlexibleItemWidth(centerItem: Bool, scrollingMode: MenuScrollingMode)
case FixedItemWidth(width: CGFloat, centerItem: Bool, scrollingMode: MenuScrollingMode)
case SegmentedControl
}
public enum MenuScrollingMode {
case ScrollEnabled
case ScrollEnabledAndBouces
case PagingEnabled
}
if centerItem
is true, selected menu item is always on center
if MenuScrollingMode
is ScrollEnabled
or ScrollEnabledAndBouces
, menu view allows scrolling to select any menu item
if MenuScrollingMode
is PagingEnabled
, menu item should be selected one by one
- menu item mode
public var menuItemMode = MenuItemMode.Underline(height: 3, color: UIColor.whiteColor(), horizontalPadding: 0, verticalPadding: 0)
public enum MenuItemMode {
case None
case Underline(height: CGFloat, color: UIColor, horizontalPadding: CGFloat, verticalPadding: CGFloat)
case RoundRect(radius: CGFloat, horizontalScale: CGFloat, verticalScale: CGFloat, selectedColor: UIColor)
}
import PagingMenuController
to use PagingMenuController in your file.
let viewController = self.storyboard?.instantiateViewControllerWithIdentifier("ViewController") as! ViewController
viewController.title = "Menu title"
let viewControllers = [viewController]
let pagingMenuController = self.childViewControllers.first as! PagingMenuController
let options = PagingMenuOptions()
options.menuHeight = 60
options.menuDisplayMode = PagingMenuOptions.MenuDisplayMode.FlexibleItemWidth(centerItem: true, scrollingMode: PagingMenuOptions.MenuScrollingMode.PagingEnabled)
pagingMenuController.setup(viewControllers: viewControllers, options: options)
- You should add
ContainerView
into your view controller's view and setPagingMenuController
as the embedded view controller's class
let viewController = UIViewController()
viewController.title = "Menu title"
let viewControllers = [viewController]
let options = PagingMenuOptions()
options.menuItemMargin = 5
options.menuDisplayMode = PagingMenuOptions.MenuDisplayMode.SegmentedControl
let pagingMenuController = PagingMenuController(viewControllers: viewControllers, options: options)
self.addChildViewController(pagingMenuController)
self.view.addSubview(pagingMenuController.view)
pagingMenuController.didMoveToParentViewController(self)
pagingMenuController.delegate = self
func willMoveToMenuPage(page: Int) {
}
func didMoveToMenuPage(page: Int) {
}
iOS8 or later
Swift 1.2 or later
Xcode 6.3 or later
PagingMenuController is available through CocoaPods. To install it, simply add the following line to your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod "PagingMenuController"
Then, run pod install
In case you haven't installed CocoaPods yet, run the following command
$ gem install cocoapods
PagingMenuController is available through Carthage.
To install PagingMenuController into your Xcode project using Carthage, specify it in your Cartfile:
github "kitasuke/PagingMenuController"
Then, run carthage update
You can see Carthage/Build/iOS/PagingMenuController.framework
now, so drag and drop it to Linked Frameworks and Libraries
in General menu tab with your project.
Add the following script to New Run Script Phase
in Build Phases menu tab.
/usr/local/bin/carthage copy-frameworks
Also add the following script in Input Files
$(SRCROOT)/Carthage/Build/iOS/PagingMenuController.framework
In case you haven't installed Carthage yet, run the following command
$ brew update
$ brew install carthage
Copy all the files in Pod/Classes
directory into your project.
PagingMenuController is available under the MIT license. See the LICENSE file for more info.