Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing the image from a UIbutton at runtime?

Tags:

I want to remove a UIButton's image and replace it with a title at runtime. Although I am able to add the title to the UIButton, I am unable to remove the image. Does anyone have some advice?

like image 615
Prabh Avatar asked Mar 02 '11 17:03

Prabh


2 Answers

Like that? [myButton setImage:nil forState:UIControlStateNormal];

like image 116
malinois Avatar answered Oct 04 '22 14:10

malinois


Your image must be the button's background image (otherwise you would not see your title text, the image property overrides the title property I believe). So you must do:

[myButton setBackgroundImage:nil ... 
like image 30
Bogatyr Avatar answered Oct 04 '22 16:10

Bogatyr