UIBarButtonItem中有个传入UIView的方法.可以快速的创建UIBarButtonItem(关键是可以自定义).
- (instancetype)initWithCustomView:(UIView *)customView;
在iOS11以上的时候传入个UIButton什么的都美滋滋.然而在iOS11以下,传入UIButton的时候却没有了显示.
解决方法:
UIView一定要有frame.如果是UILabel或者是UIButton,可以调用一下-(void)sizeToFit;
然后使用- (instancetype)initWithCustomView:(UIView *)customView;来创建UIBarButtonItem.
赋值给left或者是rightbarbuttonitem就能够显示了
重点: 使用initWithCustomView创建的UIBarButtonItem在iOS11一下需要有frame才会显示正常.