【发布时间】:2017-09-29 08:26:06
【问题描述】:
我注意到 iOS 11 对 UIBarButtonItem 进行了一些更改。解决了 UIBarButtonItem 的图片尺寸问题后,我发现自己又遇到了一个更奇怪的问题。
我们有一个带有多个 UIBarButtonItems 的 UIToolBar,我们之前将 UIBarButtonItem 的宽度设置为 40,将 UIButton.image 的宽度设置为 24,这样每两个 UIBarButtonItems 之间就有一个很好的间距。但是,在 iOS 11 中,空间消失了。
我试过了
[self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(40, 24));
}];
NSLayoutConstraint *w = [self.deleteButton.imageView.widthAnchor constraintEqualToConstant:24];
NSLayoutConstraint *h = [self.deleteButton.imageView.widthAnchor constraintEqualToConstant:24];
w.active = YES;
h.active = YES;
但它并没有像我想象的那样工作。
我要么得到一个带有 CGSize(40, 24) 的拉伸图像列表,要么得到一个带有 CGSize(24, 24) 的 UIBarButtonItem 列表,在 UINavigationBar 中一一排列,没有间距。
我需要添加任何其他约束来创建间距吗?
【问题讨论】:
标签: uinavigationbar frame uibarbuttonitem nslayoutconstraint ios11