截图
使用方法
1-在您想要显示标签的 ViewController
中继承 AMPagerTabsViewController
class ViewController: AMPagerTabsViewController {
.....
2-在 viewDidLoad
中,将 viewControllers 设置为您 viewcontrollers 数组
override func viewDidLoad() {
super.viewDidLoad()
// to change the font
self.tabFont = UIFont.systemFont(ofSize: 17, weight: .bold)
self.viewControllers = getTabs()
}
func getTabs() -> [UIViewController]{
// instantiate the viewControllers
let airplaneViewController = self.storyboard?
.instantiateViewController(withIdentifier: "airplaneViewController")
let giftViewController = self.storyboard?
.instantiateViewController(withIdentifier: "giftViewController")
let shoeViewController = self.storyboard?
.instantiateViewController(withIdentifier: "shoeViewController")
// set the title for the tabs
airplaneViewController?.title = "Airplane"
shoeViewController?.title = "Shoe"
giftViewController?.title = "Gift"
return [airplaneViewController!,giftViewController!,shoeViewController!]
}
自定义
为了自定义标签,在设置 viewControllers 之前使用设置对象
override func viewDidLoad() {
super.viewDidLoad()
self.settings.tabBackgroundColor = UIColor.red
self.settings.tabButtonColor = UIColor.red
self.settings.initialTabWidth = 100
self.settings.pagerBackgroundColor = UIColor.white
self.settings.tabButtonTitleColor = UIColor.white
self.settings.tabHeight = 100
}
安装
AMPagerTabs 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中:
pod 'AMPagerTabs'
🚀
支持我您可以通过以下方式支持此项目:
1- 检查我的 应用。
2- 收藏仓库。
3- 与你的朋友们分享仓库。
4- 给我买杯咖啡。
❤️
关注我Facebook | Twitter | Instagram | Youtube
许可证
The MIT License (MIT)
Copyright (c) 2017 Abedalkareem Omreyh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.