Giter Club home page Giter Club logo

pagingmenucontroller's Introduction

CI Status Carthage compatible Version License Platform

Updates

See CHANGELOG for details

Description

Flexible menu width mode

Fixed menu width mode

Segmented control mode

Customization

  • 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
  • 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(), selectedColor: UIColor.blueColor())
public enum MenuItemMode {
    case None
    case Underline(height: CGFloat, color: UIColor, selectedColor: UIColor)
    case RoundRect(radius: CGFloat, horizontalScale: CGFloat, verticalScale: CGFloat, selectedColor: UIColor)
}

Usage

import PagingMenuController to use PagingMenuController in your file.

Using Storyboard

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 set PagingMenuController as the embedded view controller's class

Coding only

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)

Manual

Copy all the files in Pod/Classes directory into your project.

Requirements

iOS8 or later
Swift 1.2 or later
Xcode 6.3 or later

Installation

CocoaPods

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

Carthage

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

License

PagingMenuController is available under the MIT license. See the LICENSE file for more info.

pagingmenucontroller's People

Contributors

kitasuke avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.