向 UIView 添加背景图像的正确方法是什么?
在几个论坛上读到,使用“colorWithPatternImage”添加背景图像会比平常消耗更多的内存。
坏方法:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
更好的解决方案:
UIImageView* iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]]; iv.userInteractionEnabled = YES;
self.view = iv;
[iv release];
我对此有两个问题!哪种解决方案更好?为什么? 我还想弄清楚如何将标签放置在 imageView 的顶部。
Did read on couple of forums that adding a background image with "colorWithPatternImage" will consume more memory than usual.
The bad way:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
Better solution:
UIImageView* iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]]; iv.userInteractionEnabled = YES;
self.view = iv;
[iv release];
I have two question regarding this! which solution is better ? And why ?
I am also trying to figure out how to place my labels on the top of the imageView.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)