开发者

Set Image of UIButton Created in Interface Builder, by code

I've got a number of UIButtons set up in Interface Builder (but all linked with appropriate outlet names). These buttons have images set up using the inspector in Interface Builder.

I would however, like to be able to change the images shown in the buttons during a certain event (so for example the user selects an appropriate settings choice and all the buttons c开发者_StackOverflowhange from displaying an image of a frog, to an image of a rabbit).

Is there a straight forward way of doing this? The change must be immediate, not on the next load.

Many thanks


Would something like, this work for you?

[button setBackgroundImage:[UIImage imageNamed:@"frog.png"] forState:UIControlStateNormal];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜