开发者

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!


Use this UIButton's propriety for your button.

    avatarButton.clipsToBounds = YES;


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜