LXPageViewWithButtonsViewController 0.1.2

LXPageViewWithButtonsViewController 0.1.2

测试已测试
Lang语言 SwiftSwift
许可证 MIT
Released最后发布2016年8月
SPM支持 SPM

Li Xian 维护。




  • 作者
  • Li Xian

LXPageViewWithButtonsViewController

LXPageViewWithButtonsViewController 封装了 UIPageViewController,并提供了一个可滚动的页面选择按钮。它的目的是提供一个高度可定制的 UI 组件。

它受到了 RKSwipeBetweenViewControllers 的启发。虽然 RKSwipeBetweenViewControllers 将按钮固定在导航栏中,但 LXPageViewWithButtonsViewController 允许您将选择按钮放在您喜欢的地方。

使用方法

添加视图控制器。

按钮标签将被设置为相应视图控制器的标题

import LXPageViewWithButtonsViewController // import is needed if it is installed by CocoaPods
...
let pwbVC = LXPageViewWithButtonsViewController()
pwbVC.viewControllers = [someViewController0, someViewController1, someViewController2]

自定义外观

外观自定义是在 LXButtonsScrollView.appearance 属性下分组的

/// set appreance globally
LXButtonsScrollView.appearance.button.foregroundColor.normal = UIColor.Presets.TapLightGray.color
LXButtonsScrollView.appearance.button.foregroundColor.selected = UIColor.Presets.TextBlack.color
LXButtonsScrollView.appearance.selectionIndicator.color = UIColor.Presets.TextBlack.color

/// set appearance for a particular view controller
let pwbVC = LXPageViewWithButtonsViewController()
pwbVC.buttonsScrollView.appearance.button.width = 70
pwbVC.buttonsScrollView.appearance.button.height = 40

支持的定制列表可以在 LXButtonsScrollViewAppearance.swift 中找到

  appearance.button.font.normal
  appearance.button.font.selected
  appearance.button.foregroundColor.normal
  appearance.button.foregroundColor.selected
  appearance.button.backgroundColor.normal
  appearance.button.backgroundColor.selected
  appearance.button.width
  appearance.button.height
  appearance.button.margin
  appearance.button.gap
  appearance.selectionIndicator.color
  appearance.selectionIndicator.height

对于进一步的自定义,可以通过 LXButtonsScrollViewAppearance.buttonsScrollView.buttons 访问按钮。

选择按钮的位置

默认情况下,选择按钮位于页面视图控制器顶部。您可以通过重写 LXPageViewWithButtonsViewController.lx_LayoutViews 来更改布局。

override func lx_LayoutViews() {
  /// do layout you want here
  /// the container view for selection buttons can be accessed by self.buttonsScrollView
  /// the view for the page view controller is self.pageViewController.view
}

安装

LXPageViewWithButtonsViewController 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中:

use_frameworks!
pod "LXPageViewWithButtonsViewController"

use_frameworks!
pod 'LXPageViewWithButtonsViewController', :git=> 'https://github.com/lxian/LXPageViewWithButtonsViewController.git'

作者

Li Xian, [email protected]

许可证

LXPageViewWithButtonsViewController 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。