Skip to content

SwipePager is UIPageViewController wrapper like Gunosy, SmartNews UI.

License

Notifications You must be signed in to change notification settings

applideveloper/SwipePager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwipePager

Platform Language License Issues

SwipePager is UIPageViewController wrapper like Gunosy, SmartNews UI.

Version

  • current vesion 1.1.0

Requirements

  • iOS8 and up
  • Swift 1.1
  • XCode 6.2

Installation

using CocoaPods

add the following line to your Podfile:

pod 'SwipePager'

and import

import SwipePager

manual

  • add SwipePager.swift and SwipePagerMenu.swift in Source/ to your project.

Usage

1. protocol declaration

SwipePagerDataSourceSwipePagerDelegate

class ViewController: UIViewController, SwipePagerDataSource, SwipePagerDelegate

2. SwipePager initialize

initialize and need call reloadData()

override func viewDidLoad() {
    super.viewDidLoad()

    let swipePager = SwipePager(frame: frame, transitionStyle: .Scroll)
    swipePager.dataSource = self
    swipePager.delegate = self
    self.view.addSubview(swipePager)
    swipePager.reloadData()
}

3. SwipePagerDataSource Protocol

func sizeForMenu(#swipePager: SwipePager) -> CGSize

func sizeForMenu(#swipePager: SwipePager) -> CGSize {
    return CGSizeMake(80, 50)
}

func menuViews(#swipePager: SwipePager) -> [SwipePagerMenu]

func menuViews(#swipePager: SwipePager) -> [SwipePagerMenu] {
    // use SwipePagerMenu Class
    var array: [SwipePagerMenu] = []

    for var i = 0; i < 8; i++ {
        var menu = SwipePagerMenu()
        // customize color
        menu.stateNormalColor = UIColor.lightGrayColor()
        menu.stateNormalFontColor = UIColor.whiteColor()
        menu.stateHighlightColor = UIColor.blackColor()
        menu.stateHighlightFontColor = UIColor.whiteColor()
        // label title
        if i == 0 { menu.title = "0" }
        if i == 1 { menu.title = "1" }
        if i == 2 { menu.title = "2" }
        array.append(menu)
    }

    return array
}

func viewControllers(#swipePager: SwipePager) -> [UIViewController]

func viewControllers(#swipePager: SwipePager) -> [UIViewController] {
    var array: [UIViewController] = []

    for var i = 0; i < 8; i++ {
        let viewController = UIViewController()
        // viewController setting...
        array.append(viewController)
    }

    return array
}

4. SwipePagerDelegate Protocol

func swipePager(#swipePager: SwipePager, didMoveToPage page: Int) {
       println("move to :" + page.description)
}

SwipePagerMenu Class

property

title: menu title.

font: menu font.

stateNormalColor: state normal menu color.

stateNormalFontColor: state normal font color.

stateHighlightColor: state highlight menu color.

stateHighlightFontColor: state highlight font color.

Option

currentPage

can setting start page.
SwipePager Class property. (default 0)

swipePager.currentPage = 2

swipeEnabled

disEnabled swipe gesture.
SwipePager Class property. (default true)

swipePager.swipeEnabled = false

License

The MIT License (MIT)

Copyright (c) 2015 naoto yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

SwipePager is UIPageViewController wrapper like Gunosy, SmartNews UI.

Resources

License

Stars

Watchers

Forks

Packages

No packages published