AZTabBarController不坚持到底

时间:2019-03-03 23:25:05

标签: swift

我正在尝试在我的项目中实现AZTabBarController,但我正在努力将条形图固定在屏幕底部。我的假设是,可以使用某种方法将钢筋固定在底部,或者我有一些因素将钢筋推高了50个百分点。也许存在某种程度的余量,使标杆无法停留在底部。任何建议将不胜感激。

这是我的AZTabBar代码。我是从仓库中的示例中借来的。

class CustomTabBarController:  UITabBarController {

var tabController: AZTabBarController!

override func viewDidLoad() {
    super.viewDidLoad()

    var icons = [UIImage]()
    icons.append(UIImage.init(named: "ic_home")!)
    icons.append(UIImage.init(named: "ic_new")!)
    icons.append(UIImage.init(named: "ic_settings")!)

    //The icons that will be displayed for each tab once they are selected.
    var selectedIcons = [UIImage]()
    selectedIcons.append(UIImage.init(named: "ic_home")!)
    selectedIcons.append(UIImage.init(named: "ic_new")!)
    selectedIcons.append(UIImage.init(named: "ic_settings")!)


    tabController = AZTabBarController.insert(into: self, withTabIcons: icons, andSelectedIcons: selectedIcons)

    tabController.delegate = self

    tabController.setViewController(QueryViewController.instance(), atIndex: 0)

    tabController.setViewController(SettingsViewController.instance(), atIndex: 2)

    //customize


    let color = UIColor(red: 14.0/255, green: 122.0/255, blue: 254.0/255, alpha: 1.0)

    tabController.selectedColor = color

    tabController.highlightColor = color

    tabController.highlightedBackgroundColor = #colorLiteral(red: 0.1803921569, green: 0.8, blue: 0.4431372549, alpha: 1)

    tabController.defaultColor = .lightGray

    //tabController.highlightButton(atIndex: 2)

    tabController.buttonsBackgroundColor = UIColor(red: (247.0/255), green: (247.0/255), blue: (247.0/255), alpha: 1.0)//#colorLiteral(red: 0.2039215686, green: 0.2862745098, blue: 0.368627451, alpha: 1)

    tabController.selectionIndicatorHeight = 0

    tabController.selectionIndicatorColor = color

    tabController.tabBarHeight = 60

    tabController.setAction(atIndex: 0) {
        //Your statments
        print("Home!")
    }

    tabController.setAction(atIndex: 1) {
        //Your statments
        print("NEW Situation!")
    }

    tabController.setAction(atIndex: 2) {
        //Your statments
        print("Settings")
    }

    tabController.animateTabChange = false
    tabController.onlyShowTextForSelectedButtons = false
    tabController.setTitle("Home", atIndex: 0)
    tabController.setTitle("New", atIndex: 1)
    tabController.setTitle("Settings", atIndex: 2)
    //tabController.font = UIFont(name: "AvenirNext-Regular", size: 12)

}

override var childForStatusBarStyle: UIViewController?{
    return tabController
}

func getNavigationController(root: UIViewController)->UINavigationController{
    let navigationController = UINavigationController(rootViewController: root)
    navigationController.title = title
    navigationController.navigationBar.isTranslucent = false
    navigationController.navigationBar.barStyle = .black
    navigationController.navigationBar.isTranslucent = false
    navigationController.navigationBar.barTintColor = #colorLiteral(red: 0.7450980544, green: 0.1568627506, blue: 0.07450980693, alpha: 1)
    return navigationController
}
}

enter image description here

1 个答案:

答案 0 :(得分:0)

子分类

class CustomTabBarController:  UITabBarController {

是您应直接使用AZTabBarController的原因,在底部的空白处是父类的tabBar,该空白为空,因为您没有为其设置任何viewControllers