使用button加载网络图片显示异常
iOS11之前正常:
self.leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.leftButton addTarget:self action:@selector(leftDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
self.leftButton.frame = RECT(0, 0, 36, 36);
self.leftButton.clipsToBounds = YES;
self.leftButton.layer.cornerRadius = 16;
self.leftButton.layer.borderColor = RGBAHex(0xffffff,0.5).CGColor;
self.leftButton.layer.borderWidth = 1;
self.leftButton.adjustsImageWhenHighlighted = NO;
UIBarButtonItem * leftDrawerButton = [[UIBarButtonItem alloc] initWithCustomView:self.leftButton];
[self.navigationItem setLeftBarButtonItem:leftDrawerButton animated:YES];
iOS11:
self.leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.leftButton addTarget:self action:@selector(leftDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
self.leftButton.frame = RECT(0, 0, 36, 36);
self.leftButton.clipsToBounds = YES;
self.leftButton.layer.cornerRadius = 16;
self.leftButton.layer.borderColor = RGBAHex(0xffffff,0.5).CGColor;
self.leftButton.layer.borderWidth = 1;
self.leftButton.adjustsImageWhenHighlighted = NO;
UIBarButtonItem * leftDrawerButton = [[UIBarButtonItem alloc] initWithCustomView:self.leftButton];
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 11.0) {
[self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.equalTo(CGSizeMake(36, 36));
}];
}
[self.navigationItem setLeftBarButtonItem:leftDrawerButton animated:YES];
本文探讨了在iOS11中遇到自定义UIBarButtonItem加载网络图片时出现的显示异常情况,对比了iOS11之前版本的正常表现,并提供了相应的解决方案。
1万+

被折叠的 条评论
为什么被折叠?



