测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
Released最后发布 | 2016年8月 |
SPM支持 SPM | ✗ |
由 Li Xian 维护。
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 文件。