仅在iOS10上按下视图控制器时,navigationItem titleView中的自定义视图才会跳转

时间:2018-07-17 03:29:46

标签: ios swift navigationbar uinavigationitem

我正在尝试为UILabel的{​​{1}}设置自定义navigationItem。在titleView中,我有以下代码:

viewDidLoad

这在iOS 11+上运行良好,但是如果我在 iOS 10 中按此视图控制器,则标签似乎会在屏幕上进一步启动,然后跳下位置。请参阅以下gif:

enter image description here

任何想法可能是什么原因导致的,如何解决?尝试将代码移至override func viewDidLoad() { super.viewDidLoad() let subtopicLabel = UILabel() subtopicLabel.translatesAutoresizingMaskIntoConstraints = false subtopicLabel.text = subtopicName subtopicLabel.font = UIFont.systemFont(ofSize: 20.0) subtopicLabel.textColor = ThemeService.text120 let width: CGFloat = view.frame.width * 0.7 subtopicLabel.widthAnchor.constraint(equalToConstant: width).isActive = true subtopicLabel.heightAnchor.constraint(equalToConstant: 40).isActive = true navigationItem.titleView = subtopicLabel } viewDidLayoutSubviews,尽管没有运气。任何对此的指针将不胜感激!谢谢!

0 个答案:

没有答案
相关问题