iOS UIButton在分配图像时不加载图像

时间:2014-04-30 19:43:06

标签: ios objective-c uibutton

我试图将"图像" 分配给"按钮" ,但由于理由"图像" 无法加载。

    UIImage *bottonImage = [UIImage imageNamed:@"bocinaMute.png"];

    [self.botton.imageView setImage:[UIImage imageNamed:@"mute.png"]];

当我在控制台中打印时,imageView的值为:

po _botton.imageView
<UIImageView: 0x15f53a390; frame = (0 0; 0 0); clipsToBounds = YES; hidden = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x170235c20>>

我做错了什么?

1 个答案:

答案 0 :(得分:5)

使用此:

[btnTwo setImage:[UIImage imageNamed:@"mute.png"] forState:UIControlStateNormal];

而不是

[self.botton.imageView setImage:[UIImage imageNamed:@"mute.png"]];