FATabScroller
FATabScroller 是一个完全可定制的控件,它包含一组分层页面,每次只显示一个页面。
需求
- Xcode 8.0+
- Swift 3.0+
安装
FATabScroller 通过 CocoaPods 提供。您可以使用以下命令进行安装
$ gem install cocoapods
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'FATabScroller', '~> 1.0.0'
end
然后运行以下命令
$ pod install
用法
属性
tabBarBackgroundColor {UIColor}
- 标签栏的背景颜色。tabBarColor {UIColor}
- 栏图标颜色。animate {Bool}
- 标记卡片滚动是否启用/禁用。
事件
beforeTabChange
- 在标签更改之前触发。返回 false 以取消标签更改。tabChange
- 当激活新标签时触发。
示例
import FATabScroller
import Font_Awesome_Swift
class ViewController: UIViewController, FATabPanelDelegate {
let tabPanel: FATabPanel = {
let v = FATabPanel()
v.tabBarBackgroundColor = UIColor.orange
v.tabBarColor = UIColor.white
return v
}()
override func viewDidLoad() {
super.viewDidLoad()
// Delegation
tabPanel.shared = self
view.addSubview(tabPanel)
tabPanelConfig()
layout()
}
func layout() {
tabPanel.constraintsStretch()
}
func tabPanelConfig() {
let view1 = UIView(), view2 = UIView(), label1 = UILabel(), label2 = UILabel()
label1.text = "View 1"
label2.text = "View 2"
label1.addSCConstraints { sc in
view1.addSubview(sc)
sc.constraintWithAttribute(to: view1, attribute: .center)
}
label2.addSCConstraints { sc in
view2.addSubview(sc)
sc.constraintWithAttribute(to: view2, attribute: .center)
}
tabPanel.items = [
FATabPanelItem(title: .FAHome, card: view1),
FATabPanelItem(title: .FAMap, card: view2)
]
}
// MARK: FATabPanelDelegate
func beforeTabChange() -> Bool {
print("beforetabchange event")
return true
}
func tabChange() {
print("ontabchange event")
}
}
许可证
FATabScroller 采用 MIT 许可证发布。详细信息请参阅 LICENSE。