中心垂直对齐导航元素

时间:2017-05-12 14:47:31

标签: ios swift swift3 uinavigationbar

我的应用程序要求导航栏超出常规尺寸,增加尺寸,我添加了以下类并分配给故事板中的导航控制器

class CustomNavigationBar: UINavigationBar {

    override func sizeThatFits(_ size: CGSize) -> CGSize {
        return CGSize(width: UIScreen.main.bounds.width, height: 70)
    }

    override func awakeFromNib() {
        let attribtutes = [
            NSFontAttributeName: UIFont(name: "Montserrat-Light", size: 18)!,
            NSForegroundColorAttributeName: UIColor.black,
            NSKernAttributeName: 5.0
            ] as [String : Any]
        UINavigationBar.appearance().titleTextAttributes = attribtutes
        UINavigationBar.appearance().tintColor = UIColor.black
        UINavigationBar.appearance().backgroundColor = UIColor.green
    }
}

这会增加尺寸,但导航栏项目会放在底部。 (参见下面的截图)

enter image description here

我要找的是垂直居中对齐标题和后退按钮。我还想稍微向后移动后退按钮。

我尝试了多种选择,但似乎没有任何效果。任何有关如何去做的帮助都表示赞赏。

感谢。

0 个答案:

没有答案
相关问题