2017-10-12 2 views
0

Ich habe zwei UIButton auf der rechten Seite der Navigationsleiste von UIViewController, UIbuttons haben Bilder. Die App funktionierte gut, bis sie in Xcode 8 lief, aber wenn ich Xcode 9 aktualisierte, wird es nicht gerendert, es dauert ganze Navigationsleiste. In Xcode 8 war es enter image description hereBild in Navigationsleiste Schaltfläche nicht nach dem Update auf Xcode 9

aber nach 9 bis Xcode Aktualisierung sieht es aus wie dieses

enter image description here

Mein Code navbar auf Einstellung ist ...

func setUpNavBar(){ 
    self.navigationController?.navigationBar.isTranslucent = false 
    self.navigationItem.setHidesBackButton(true, animated: true) 


    let notificationBtn = UIButton(type: .custom) 
    notificationBtn.setImage(UIImage(named: "notificationIcon"), for: .normal) 
    notificationBtn.frame = CGRect(x: 0, y: 0, width: 35, height: 35) 
    notificationBtn.addTarget(self, action: #selector(HomeViewController.notificationClicked), for: .touchUpInside) 
    let item1 = UIBarButtonItem(customView: notificationBtn) 

    let profileBtn = UIButton(type: .custom) 
    profileBtn.setImage(UIImage(named: "user_profile"), for: .normal) 
    profileBtn.frame = CGRect(x: 0, y: 0, width: 35, height: 35) 
    profileBtn.addTarget(self, action: #selector(HomeViewController.ProfileClicked), for: .touchUpInside) 
    let item2 = UIBarButtonItem(customView: profileBtn) 
    self.navigationItem.setRightBarButtonItems([item1,item2], animated: true) 

} 

Ich bin sehr verwirrt, warum es passiert.

Antwort

2

In iOS 11 müssen Sie/set Einschränkungen Höhe hinzuzufügen und mit der UIButton

Für notificationBtn

let widthConstraint = notificationBtn.widthAnchor.constraint(equalToConstant: 35) 
let heightConstraint = notificationBtn.heightAnchor.constraint(equalToConstant: 35) 
heightConstraint.isActive = true 
widthConstraint.isActive = true 

gleichen Bewerben profileBtn zu.

+0

ich denke, du solltest als duplikat lol markieren –

+1

Es funktioniert dank mann – Prathamesh

Verwandte Themen