user1105951
user1105951

Reputation: 2287

UIButton with UIImage . changing the frame after setting the button's image to nil will not remove image

I can "fix" the problem with simple if and not changing the frame if there is no image.. but I want to make sure I'm not missing something.

I had a bug when the image in the button was not clear after setting it to nil, but it happen only in some cases.

After debugging I saw that if I change the frame after I set the image with nil, that Image still appear.

Is there a way to clear the image in the UIButton, that will clear the image no matter what ?

thanks.

Upvotes: 0

Views: 523

Answers (1)

keen
keen

Reputation: 3011

do this.

if[myButton imageForState:UIControlStateNormal]!=nil)
{
       [myButton setImage:nil forState:UIControlStateNormal];
}

Upvotes: 1

Related Questions