在设置UIButton时发现加入的图片不能显示,通过调试发现imageView的hidden属性为YES,并且frame为0。
所以,在建立一个button后要手动设置一下它的imageView.hidden和imageView.frame属性,方可正常显示图片。
//分享按钮
self.shareBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width, 0, self.height, self.height)];
self.shareBtn.backgroundColor = [UIColor redColor];
self.shareBtn.imageView.frame = self.shareBtn.bounds;
self.shareBtn.hidden = NO;
self.shareBtn.imageView.image = [UIImage imageNamed:@"btn_forwarding_focused.png"];
本文介绍了一个UIButton在iOS应用中无法正确显示图片的问题及其解决方案。通过调整imageView的hidden属性和frame属性,确保了图片能够正常加载和显示。
5784

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



