页视图容器
页视图的简单容器。
安装
Cocoapods
pod 'PagedViewContainer', '~> 0.2.2'
详情
使用UIView
而不是UIViewController
。可以通过PagedViewContainerConfig
进行配置。您可以在运行时禁用一些页面并隐藏它们。
用法
在/Examples文件夹中查看更多示例。
配置
let config = PagedViewContainerConfig(
pagesBackgroundColor: .white,
menuBackgroundColor: .lightGray,
activeItemTextColor: .black,
inactiveItemTextColor: .gray,
indicatorColor: .black)
将容器添加到您的视图中
let bestConfig: PagedViewContainerConfig = ...
let greatView: UIView = ...
let awesomeView: UIView = ...
let items = [
PageItem(title: "Great view", view: greatView),
PageItem(title: "Awesome view", view: awesomeView)
]
let pagedContainer = PagedViewContainer(config: bestConfig)
pagedContainer.setup(with: items)
yourView.addSubview(pagedContainer)
禁用/启用页面
pageContainer.set(page: 1, isEnabled: false)