【发布时间】:2017-10-03 02:46:20
【问题描述】:
我有一个自定义应用程序,其中包含一个自定义栏按钮项,在 Swift 3 中它的大小已适当,但在更新到 Swift 4 后,它不再根据所提供的约束调整大小。这是我的代码:
let infoButton = UIButton.init(type: .custom)
infoButton.setImage(UIImage(named: "info button white.png"), for: UIControlState.normal)
infoButton.addTarget(self, action: #selector(StartViewController.infoButtonPressed), for: UIControlEvents.touchUpInside)
infoButton.frame = CGRect(x: 0, y: 0, width: 25, height: 25)
let barButton = UIBarButtonItem(customView: infoButton)
self.navigationItem.rightBarButtonItem = barButton
我尝试更改 CGRect 数字,看看是否有任何变化,但没有,它的大小已达到导航栏的限制,坦率地说现在看起来很丑。
【问题讨论】:
-
问题可能出在 iOS 11 上。我在另一部运行 iOS 10.3.2(14F89) 的手机上运行了该应用程序,并且信息按钮的大小合适,在我的第一台运行 iOS 11.0.1 的设备上运行(15A402) 我明白了。
标签: ios swift uinavigationbar