AASlidingTopTabBar




AASlidingTopTabBar 允许您创建适用于 Android 标签控制器样的顶部标签的 UITabBar。AASlidingTopTabBar 专为 Swift 编写,具有以下功能。
特点
- 高度可定制化。
- 使用 Pod 进行安装
如何使用
在您想要添加标签栏的 ViewController.swift 文件中,请添加以下代码
class ViewController: UIViewController,AASlidingTabControllerDelegate {
var controllerArray = [UIViewController]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
createTabController()
}
func createTabController() {
let pendingEventsVC = self.storyboard?.instantiateViewController(withIdentifier: "PendingEventsVC") as! PendingEventsVC
pendingEventsVC.title = "Pending Events"
let completedEventsVC = self.storyboard?.instantiateViewController(withIdentifier: "CompletedEventsVC") as! CompletedEventsVC
completedEventsVC.title = "Completed Events"
let cancelledEventsVC = self.storyboard?.instantiateViewController(withIdentifier: "CancelledEventsVC") as! CancelledEventsVC
cancelledEventsVC.title = "Cancelled Events"
controllerArray.append(pendingEventsVC)
controllerArray.append(completedEventsVC)
controllerArray.append(cancelledEventsVC)
let vc = AASlidingTabController()
vc.delegate = self
vc.indicatorTintColor = UIColor(red: 169.0/255.0, green: 1.0/255.0, blue: 25.0/255.0, alpha: 1.0)
vc.indicatorHeight = 5.0
vc.selectedTabTitleColor = UIColor(red: 169.0/255.0, green: 1.0/255.0, blue: 25.0/255.0, alpha: 1.0)
vc.unSelectedTabTitleColor = UIColor(red: 169.0/255.0, green: 1.0/255.0, blue: 25.0/255.0, alpha: 0.6)
vc.titleLetterSpacing = 1.0
vc.initialSelectedTabIndex = 1
vc.initWithViewController(controllers: controllerArray, parentViewController: self, forHeight: 40.0)
self.view.addSubview(vc.view)
}
}
当用户更改标签时收到通知
//MARK:- AASlidingTabBarControllerDelegate
func currentSelectedIndex(_ index: Int) {
print("Selcted tab index = \(index)")
}
MIT 许可证 (MIT)
版权所有 (c) 2019-至今 Aman Aggarwal
本文件授予任何人免费获得该软件及其相关文档(以下简称“软件”)副本的权利,包括但不仅限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许获得软件的个人进行此类操作,但须遵守以下条件:
上述版权声明和本许可声明应包含于软件的所有副本或主要部分。
软件按“现状”提供给用户,不提供任何形式的保证,明示或暗示,包括但不限于关于其适用性、特定目的适用性和非侵权的保证。在任何情况下,作者或版权所有者均不对因软件或其使用、操作或其他参与软件而产生的任何索赔、损害或其他责任承担责任,无论这些责任是基于合同、侵权或其他方式。