0
votes

The method - (void)setImage:(UIImage *)image forState:(UIControlState)state of UIButton.

Since if you have not set an image for the Selected state, then the Normal image will also appear when the button isSelected.

I mean I want to set image for normal state and only title(no image) for selected?

Sorry my English!

1

1 Answers

0
votes

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];