2017-09-21 135 views
0

有一个小问题,我的NavBar按钮atm。我升级到了Xcode 9/ios 11,突然间UIBarButtonItems曾经是导航栏侧面的小按钮(比如你的后背或者标准ios应用中的编辑按钮)已经开始大规模拉伸了。这里有一张照片:奇怪的NavBar拉伸在ios 11 Xcode 9

The Problem

我的代码很简单:

self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: image2, style: .plain, target: self, action: #selector(messageScreen)) 

有谁知道如何解决这一问题?谢谢。

回答

3
let widthConstraint = button.widthAnchor.constraint(equalToConstant: 30) 
    let heightConstraint = button.heightAnchor.constraint(equalToConstant: 30) 
    heightConstraint.isActive = true 
    widthConstraint.isActive = true 

// add those lines before setting navigation buttons 
+0

你能给我这个代码的objective-c版本吗? – priyadharshini

+1

对不起ı不知道客观-c。 –

+0

谢谢你解决它就好! –