Commit 0a873b75 by Orkhan Alikhanov

Added support for heightPreset in BottomNavigationController

parent 76e60ab6
......@@ -41,6 +41,15 @@ extension UIViewController {
}
}
private class MaterialTabBar: UITabBar{
override func sizeThatFits(_ size: CGSize) -> CGSize {
var v = super.sizeThatFits(size)
let offset = v.height - 49
v.height = CGFloat(heightPreset.rawValue) + offset
return v
}
}
open class BottomNavigationController: UITabBarController {
/// A Boolean that indicates if the swipe feature is enabled..
open var isSwipeEnabled = false {
......@@ -60,6 +69,7 @@ open class BottomNavigationController: UITabBarController {
*/
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setTabBarClass()
}
/**
......@@ -69,6 +79,7 @@ open class BottomNavigationController: UITabBarController {
*/
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
setTabBarClass()
}
/// An initializer that accepts no parameters.
......@@ -144,6 +155,17 @@ open class BottomNavigationController: UITabBarController {
}
private extension BottomNavigationController {
/// Sets tabBar class to MaterialTabBar.
func setTabBarClass() {
guard object_getClass(tabBar) === UITabBar.self else {
return
}
object_setClass(tabBar, MaterialTabBar.self)
}
}
private extension BottomNavigationController {
/**
Selects a view controller at a given index.
- Parameter at index: An Int.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment