Max Strater
Max Strater

Reputation: 538

UIButton setBackgroundImage back to default

I have a normal RoundedRect UIButton that I created in a UIStoryBoard. Under a certain situation I call setBackgroundImage on the button to change it's appearance. How do I then change the appearance of the UIButton back to what it was before setting the background image (the default RoundedRect look)? Calling [button setBackgroundImage:nil forState:UIControlStateNormal]; seems to result in a button with no background at all (completely transparent).

Thanks, Max

Upvotes: 0

Views: 358

Answers (1)

Giuseppe Garassino
Giuseppe Garassino

Reputation: 2292

As long as I know, when you set UIButton to RoundedRect, you tell your app to set the default image as the background of your button.

If you then change this background with a custom image, your app puts away the default image, and switches it with the new one.

Unfortunately, your app doesn't remember what was the look of your button before changing it, and it is not possible to go back.

Anyway, you can reset your UIButton these ways:

  1. Deleting and creating it again
  2. Creating a custom background image that looks like RoundedRect UIButton
  3. Using UIControlStates to set the appearance of your button

Upvotes: 1

Related Questions