iOS11 自定义导航栏item边距

iOS11下,用图片button来设置barButtonItem会无法设置Size,因为iOS11上,navigationBar相关布局修改为autolayout约束

解决:

1、在设置成barButtonItem后,添加判断

1
2
3
4
if (@available(iOS 11, *)) {
[rightBtn.widthAnchor constraintEqualToConstant:standardSize.width].active = YES;
[rightBtn.heightAnchor constraintEqualToConstant:standardSize.height].active = YES;
}
  Total:    No.