ios - iOS 11 UIBarButtonItem ImageView大小错误

标签 ios image size uinavigationbar ios11

您好,今天早上在iOS 11上,我发现了许多iOS 10所没有的错误。我纠正了除两个错误以外的大多数错误,此处的配置文件图像位于右上方

代码按钮:

UIImageView* v = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    v.image = img;
    v.layer.masksToBounds = YES;
    v.layer.cornerRadius = 17.5;

    UIBarButtonItem* rightBtn = [[UIBarButtonItem alloc] initWithCustomView:v];
    self.navigationItem.rightBarButtonItem = rightBtn;

///// iOS 10 /////

enter image description here

///// iOS 11 /////

enter image description here

最佳答案

在iOS 11中,您必须需要我们自动布局而不是框架

像下面

    myButton.widthAnchor.constraint(equalToConstant: customViewButton.width).isActive = true
    myButton.heightAnchor.constraint(equalToConstant: customViewButton.height).isActive = true

关于ios - iOS 11 UIBarButtonItem ImageView大小错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46404144/

相关文章:

ios - 将用户限制为一个小数点 UILabel Swift2

ios - 在Mac上没有管理员权限的情况下如何使用xcode?

ios - 自定义 ios tableview 单元格不工作

css - PNG颜色问题

html - 拉伸(stretch)图像以适应 td

qt - QFont PixelSize 和 QFontMetrics height 给出不同的值

ios - UIButton 圆角半径在 CustomClass 中无法正常工作

java - 如何将图片放在屏幕的左上角?

linux - Mac 上 "size"命令中的数据段大小

Android:如何更改 RadioButton 的大小