カスタムバーボタンアイテムを含むカスタムアプリがあります。スウィフト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番号を変更しようとした、そしてそこではない、それはナビゲーションバーの限界にサイジングされ、率直に言って、今はかなり見苦しいです。
スウィフト4で変更されたものについてのアイデアはありますか?
infoButton.widthAnchor.constraint(equalToConstant: 25).isActive = true
infoButton.heightAnchor.constraint(equalToConstant: 25).isActive = true
か、正しいサイズの画像を使用します。私は、Xcodeの9.0(9A235)
問題はiOS 11で発生する可能性があります。iOS 10.3.2(14F89)を実行している別の電話機でアプリを実行し、iOS 11.0.1(15A402)の最初のデバイスで情報ボタンを実行すると、問題。 – user1698875