user387184
user387184

Reputation: 11053

UIButton with changing images when pressed - but unattractive effect when changing them

I have a button that changes its image to different images depending on what modus we are in.

The images are set with:[modusBtn setImage:cx forState:UIControlStateNormal];

The images have round corners and the button is of Type "Custom".

Now when the button is pressed one can see another image in the upper and lower edge background.

Really weird - the buttons ALL have round corners - but for example when the blue modus is on and shows the blue image and one presses the blue button now - one can see red little edges only on the left two corners.

I already played around with all the button attribute settings in IB, but no luck.

Did anyone have a similar experience when changing button images?

So far all my button images where 100% rectangular and did not have round corners - therefore I never experienced this before.

Many thanks!

Upvotes: 0

Views: 308

Answers (2)

Munim
Munim

Reputation: 2778

Whenever you set an image for custom button make sure to set

yourButton.backgroundColor=[UIColor clearColor];

The effect was happening as your button was using default background transitions during changing the state.

Upvotes: 0

Naveen Thunga
Naveen Thunga

Reputation: 3675

Use this UIButton's propriety for your button.

    avatarButton.clipsToBounds = YES;

Upvotes: 1

Related Questions