SwipePager 1.1.1

SwipePager 1.1.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布Nov 2016
SwiftSwift版本2.3
SPM支持SPM

naoto0822维护。



  • naoto0822

SwipePager类似于Gunosy、SmartNews UI的UIPageViewController包装。

版本

  • 当前版本1.1.1

要求

  • iOS8及以上
  • Swift 2.3
  • Xcode 7.x

安装

手动

  • SwipePager.swiftSwipePagerMenu.swift添加到项目的Source/目录。

用法

1. 协议声明

SwipePagerDataSourceSwipePagerDelegate

 class ViewController: UIViewController, SwipePagerDataSource, SwipePagerDelegate

2. SwipePager初始化

初始化并需要调用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 协议

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 协议

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

SwipePagerMenu

属性

title: 菜单标题。

font: 菜单字体。

stateNormalColor: 状态正常菜单颜色。

stateNormalFontColor: 状态正常字体颜色。

stateHighlightColor: 状态高亮菜单颜色。

stateHighlightFontColor: 状态高亮字体颜色。

选项

currentPage

可以设置起始页面。
SwipePager 类属性。 (默认0)

swipePager.currentPage = 2

swipeEnabled

禁用滑动手势。
SwipePager 类属性。(默认为true)

swipePager.swipeEnabled = false

授权

MIT许可(MIT)

版权所有(c)2015 naoto yamaguchi

特此授予任何获得本软件及其相关文档资料(“软件”)副本的人免费权利,不受限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,并允许提供给软件的人这么做,前提是遵守以下条件:

上述版权声明和本许可声明应包含在软件的任何副本或主要部分中。

软件按“现状”提供,不提供任何形式的明示或暗示保证,包括但不限于适销性、针对特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者不应对任何索赔、损害或其他责任(无论是由合同、侵权或其他原因引起的)承担责任,无论该索赔、损害或其他责任是否源于、来自于或与软件、软件的使用或其他方式有关。