在IB中创建按钮后,UIButton setImage无法正常工作

时间:2013-01-17 19:10:13

标签: ios uibutton

我有一个IBOutlet UIButton,我添加到IB中的滚动视图。我将其类型设置为自定义,然后在viewDidLoad中我有:

[self.featuredButton setImage:[UIImage imageNamed:@"featuredNormal.png"] forState:UIControlStateNormal];
[self.featuredButton setImage:[UIImage imageNamed:@"featuredSelected.png"] forState:UIControlStateSelected];

图片没有出现......为什么不呢?

1 个答案:

答案 0 :(得分:0)

使用

[self.featuredButton setBackgroundImage:[UIImage imageNamed:@"featuredNormal.png"] forState:UIControlStateNormal];

[self.featuredButton setBackgroundImage:[UIImage imageNamed:@"featuredSelected.png"] forState:UIControlStateSelected];