奇怪的NavBar在iOS 11 Xcode 9中拉伸

Pel*_*nez 1 xcode ios swift ios11 xcode9

我的NavBar按钮atm有点问题。我升级到Xcode 9 / ios 11,突然之间,曾经是导航栏侧面的小按钮的UIBarButtonItems(例如标准ios应用程序中的后退或编辑按钮)开始大量扩展。这是一张照片:

问题

我的代码很简单:

self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: image2, style: .plain, target: self, action: #selector(messageScreen))
Run Code Online (Sandbox Code Playgroud)

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

Oka*_*kan 5

迅速:

let widthConstraint = button.widthAnchor.constraint(equalToConstant: 30)
let heightConstraint = button.heightAnchor.constraint(equalToConstant: 30)
heightConstraint.isActive = true
widthConstraint.isActive = true
Run Code Online (Sandbox Code Playgroud)

目标C:

[button.widthAnchor constraintEqualToConstant:30].active = YES;
[button.heightAnchor constraintEqualToConstant:30].active = YES;
Run Code Online (Sandbox Code Playgroud)

//在设置导航按钮之前添加这些行