开发者

iPhone:How to remove button background image programmatically?

Programmatically I am creating buttons and keeping some background image using setBackgroundImage. I want to remove the set background image in the button after some time interval. I have timer code, which will call after particular interval. At this time, i want to remove the button background image in my program. I'm done with timer code and all. I don't know how to remove button background image programmatically. How to do that removing background image from buttons? Is it possible to remove the already set background image for buttons? Can i make it null as setBackgroundImage again? I can't put white color back for button so as to like removing, because my application screen has some other color design.

A开发者_如何学编程ppreciate your help on this !

thanks.


Just use [button setBackgroundImage:nil forState:UIControlStateNormal]. However, this will give you a pretty much transparent button (except for the button title). Are you trying to hide the entire button? If so, use button.hidden = YES, or button.alpha = 0.0.


You need to hang on to a reference to your button, but as long as you have that, you should be able to call [button setBackgroundImage:nil forState:UIControlStateNormal] from your timer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜