I'm having problem figuring out how to disable the horizontal scrolling of the Tab bar from Google Material Design for iOS. I'm planning to make a fixed tab bar with 3 tabs options.
Maybe someone can help me. Thank you in advance.
Sample Code:
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)
}
}