Pager
UIPagerViewController 封装器
要求
- iOS 9.0+
- Xcode 9.2
安装
CocoaPods
您可以使用 CocoaPods 通过将其添加到 Podfile
中来安装 PagerTab
platform :ios, '9.0'
use_frameworks!
target 'YourTarget' do
pod "PagerTab"
end
要获得完整的优势,导入 PagerTab
import PagerTab
使用示例
设置 PagerTabAppearance
let appearence = PagerTabAppearance( type: PagerTabType.fixedNumber(2),
titleColors: [(.blue, .selected), (.blue, .highlighted), (.lightGray, .normal)] )
有关不同的定制选项,请查看 PagerTabAppearance
初始化
public init(type: PagerTabType,
selected: Int = 0,
height: CGFloat = 50.0,
color: UIColor? = .clear,
titleColors: [(UIColor, UIControlState)]? = [(.black, .normal)],
font: UIFont = UIFont.systemFont(ofSize: UIFont.systemFontSize) ) {
...
定义您的 viewControllers
let PoutingVC: BeautifulViewController = { let vc = BeautifulViewController(text: "😡")
vc.view.backgroundColor = UIColor.gray
return vc
}()
let BombVC: BeautifulViewController = { let vc = BeautifulViewController(text: "💣")
vc.view.backgroundColor = UIColor.lightGray
return vc
}()
let NerdVC: BeautifulViewController = { let vc = BeautifulViewController(text: "🤓")
vc.view.backgroundColor = UIColor.white
return vc
}()
let SkullVC: BeautifulViewController = { let vc = BeautifulViewController(text: "☠️")
vc.view.backgroundColor = UIColor.green
return vc
}()
设置 PagerTabPage
数组
let viewControllers: [PagerTabPage] = [( PoutingVC , "Pouting"),
( BombVC , "Bomb"),
( NerdVC , "Nerd"),
( SkullVC , "Skull") ]
初始化 PagerTab
let pager = PagerTab( viewControllers , appearence: appearence )
将其添加到您的视图中
self.add(childController: pager, toView: self.view)