Let's suppose that I want to create a custom component as UIView subclass, and i want to allow to set an image as background (for the sake of this question suppose one big image not a pattern) . I have two options:
- Create a
UIImageViewlarge as the UIView frame and set itsimageproperty - Create a pattern color with
[UIColor colorWithPattern]and set as backgroundColor
The first one is handful if you want to work with Interface Builder and want to see what you do. The second works great if you want to use a pattern, but remember we are talking about one big image.
So my question is about performance and/or best practice which one of the previous method is the best thinking about performance? Suppose, for example, this component will be moved around with an animation.
Based on your own experience there are 开发者_StackOverflow社区some drawback in one or another approach?
This answer gives you two good avenues to explore:
Memory consumption while loading a large image in uiimageview in
加载中,请稍侯......
精彩评论