显示操作表时,iPhone 4s 导航栏按钮项会下降

iPhone 4s navigation bar button item goes down when an actionsheet is presented

提问人:Burak Akyalçın 提问时间:10/21/2018 最后编辑:Burak Akyalçın 更新时间:10/21/2018 访问量:42

问:

iPhone 4s issue

该应用程序与任何其他设备完美配合,但 iPhone 4s 可以做到这一点。我使用过屏幕调试器,我可以看到它的 y 位置增加,但我不知道为什么。

这是我从 method 调用的代码片段。configureNavigationBarWithTitle()viewDidLoad()

func configureNavigationBarWithTitle(title: String, shouldDisplayHomeButton: Bool = false) {
    self.navigationController?.setNavigationBarHidden(false, animated: true)
    self.navigationItem.titleView = UIView.createNavigationTitleView(title: title)
    self.navigationItem.leftBarButtonItem = UIBarButtonItem.createAZBackButton(target: self)
    self.navigationItem.leftBarButtonItem?.action = #selector(navigateBack(sender:))

    if shouldDisplayHomeButton {
        self.navigationItem.rightBarButtonItem = UIBarButtonItem.createAZHomeButton(target: self)
        self.navigationItem.rightBarButtonItem?.action = #selector(navigateToRoot(sender:))
    }
}


extension UIBarButtonItem {
static func createAZBackButton(target: Any?) -> UIBarButtonItem {
    let img = UIImage(named: "back")
    let button = UIBarButtonItem(image: img, style: .plain, target: target, action: nil)
    button.title = ""
    button.tintColor = UIColor.white
    button.setBackgroundVerticalPositionAdjustment(0, for: .default)
    return button
}

static func createAZHomeButton(target: Any?) -> UIBarButtonItem {
    let img = UIImage(named: "home")
    let button = UIBarButtonItem(image: img, style: .plain, target: target, action: nil)
    button.title = ""
    button.tintColor = UIColor.white
    button.setBackgroundVerticalPositionAdjustment(0, for: .default)
    return button
}
iOS iPhone Swift UIDuiNavigationController UINuageBar

评论

0赞 Sateesh Yemireddi 10/21/2018
你能把所使用的代码或类似XIB文件的东西分享给我们吗,@Burak?
0赞 Burak Akyalçın 10/21/2018
添加了一些代码

答: 暂无答案