测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可 | MIT |
发布最新发布 | 2017年11月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Dylan Marriott 维护。
UITabBar 的简洁简单的替代方案。仅在触摸时显示标题。为应用程序提供了更干净的外观 :)
将 MiniTabBar.swift
和 MiniTabBarItemView.swift
拖放到您的项目中。
// First create some tab bar items:
// Icons should be a template image with the size 26 x 20 dp
var items = [MiniTabBarItem]()
items.append(MiniTabBarItem(title: "Tab Name", icon: <UIImage>))
//...
// Create a MiniTabBar instance and add it as a regular subview:
let tabBar = MiniTabBar(items: items)
tabBar.delegate = self
tabBar.frame = CGRect(x: 0, y: self.view.frame.height - 44, width: self.view.frame.width, height: 44)
self.view.addSubview(tabBar)
// Delegate protocol:
func tabSelected(_ index: Int) {
print("Selected tab: ", index)
}
以下是一些自定义 MiniTabBar 外观的方式
// Change the tint colour of an item (title & icon):
tabBar.tintColor = UIColor.red
// Change the font of the title label:
tabBar.font = UIFont.systemFont(ofSize: 10)
// Select an item programmatically:
tabBar.selectItem(2, animated: false)
// Change the background & key line of the tab bar:
tabBar.backgroundColor = UIColor.black
tabBar.backgroundBlurEnabled = false
tabBar.keyLine.isHidden = true
还可以有一个自定义视图,它不执行标签的操作。例如中间的 (+) 按钮。
let customButton = UIButton()
customButton.backgroundColor = UIColor.orange
customButton.frame.size = CGSize(width: 50, height: 50)
let customItem = MiniTabBarItem(customView: customButton,
offset: UIOffset(horizontal: 0,
vertical: -10))
customItem.selectable = false
items.append(customItem)