我不知道如何从googlematerialdesignforios中禁用标签栏的水平滚动。我打算做一个固定的标签栏,有3个标签选项。
也许有人能帮我。提前谢谢你。
示例代码:
import UIKit
import MaterialComponents
import ChameleonFramework
class ViewController: UIViewController, MDCTabBarDelegate {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
navigationController?.navigationBar.isTranslucent = false
setupView()
}
let tabBarContainer: MDCTabBar = {
let tabBar = MDCTabBar()
tabBar.barTintColor = .white
tabBar.items = [
UITabBarItem(title: "All Activities", image: nil, tag: 0),
UITabBarItem(title: "Bookmark", image: nil, tag: 0),
UITabBarItem(title: "My Journal", image: nil, tag: 0)
]
tabBar.itemAppearance = .titledImages
tabBar.autoresizingMask = [.flexibleWidth, .flexibleBottomMargin]
tabBar.sizeToFit()
tabBar.tintColor = UIColor.rgb(red: 12, green: 82, blue: 143)
tabBar.selectedItemTintColor = UIColor.rgb(red: 12, green: 82, blue: 143)
tabBar.unselectedItemTintColor = .lightGray
return tabBar
}()
func setupView() {
view.addSubview(tabBarContainer)
view.addConstraintsWithFormat("H:|[v0]|", views: tabBarContainer)
view.addConstraintsWithFormat("V:|[v0(48)]", views: tabBarContainer)
}
}
Actual sample of the issue on simulator
最佳答案
也许我迟到了,但我可以通过
tabBar.alignment = .justified