2017-09-29 21 views
0

私が抱えていた問題は、Xcode 9をダウンロードした後、私のアプリケーションのユーザーインターフェイスが狂っていることです。ナビゲーションアイテムSwift 3 to Swift 4

Xcodeの9前
let item1 = UIBarButtonItem(image: #imageLiteral(resourceName: "SettingsInto"), style: .done, target: self, action: #selector(settingsPressed)) 

    self.navigationItem.setRightBarButton(item1, animated: true) 

    let item2 = UIBarButtonItem(image: #imageLiteral(resourceName: "search icon"), style: .plain, target: self, action: #selector(searchPressed)) 
    self.navigationItem.setLeftBarButtonItem(item2, animated: true) 

    let imageButton = UIButton(frame: CGRect(x: 0, y: 0, width: 0, height: navigationBarHeight)) 
    let image = #imageLiteral(resourceName: "Stickiie Logo Main") 
    imageButton.setImage(image, for: UIControlState()) 
    imageButton.imageView?.contentMode = .scaleAspectFit 
    imageButton.addTarget(self, action: #selector(refresh), for: .touchDown) 
    self.navigationItem.titleView? = imageButton 

:Xcodeの9の後 enter image description here

enter image description here

+0

あなたは、この使用してストーリーボードを行うと、それが動作するかどうかを確認しようとすることはできますか? – azamsharp

+0

ねえ!残念ながら、それはうまくいきませんでしたが、アイコンのサイズが大きすぎるためであることがわかりました。アドバイスをいただきありがとうございます! – GhostBeard

答えて