开发者

IB vs Programmatical Creation of UIButtons

Let's say I want to create a lot of custom buttons with the same UIImage named X. Programmatically, I would create only one UIImage and add this to all the开发者_如何转开发 buttons I created. I was wondering if I created these buttons in Interface Builder would IB create only 1 UIImage X or a new UIImage X for each button? Thanks


UIImages are pooled, so repeated calls to [UIImage imageNamed:] with the same name will actually return the same UIImage instance. This should apply to objects baked into a NIB as well. Should be easy to verify, though - just print out the pointer value using

NSLog(@"%p", [button imageForState:UIControlStateNormal]);

or whatever for each button in question.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜