出现操作表时,iPhone 4s导航栏按钮项将关闭

时间:2018-10-20 16:17:02

标签: ios iphone swift uinavigationcontroller uinavigationbar

iPhone 4s issue

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

这是代码段,我从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
}

0 个答案:

没有答案