2017-09-21 77 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

謝謝你解決它就好! –