UIButton 的方法 - (void)setImage:(UIImage *)image forState:(UIControlState)state。
因为如果您没有为 Selected 状态设置图像,那么当按钮被选中时,Normal 图像也会出现。
我的意思是我想为正常状态设置图像,并且只选择标题(无图像)?
对不起我的英语!
UIButton 的方法 - (void)setImage:(UIImage *)image forState:(UIControlState)state。
因为如果您没有为 Selected 状态设置图像,那么当按钮被选中时,Normal 图像也会出现。
我的意思是我想为正常状态设置图像,并且只选择标题(无图像)?
对不起我的英语!
You call setImage:forState:
as many times as you need:
[someButton setImage:someNormalImage forState:UIControlStateNormal];
[someButton setImage:someSelectedImage forState:UIControlStateSelected];
Update: It appears you want a button that shows just an image for the normal state and just a title for the selected state. I don't know if the following will work but give it a try:
[someButton setImage:someNormalImage forState:UIControlStateNormal];
[someButton setImage:nil forState:UIControlStateSelected];
[someButton setTitle:@"Some Title" forState:UIControlStateSelected];