开发者

UIView background

开发者 https://www.devze.com 2023-03-13 06:51 出处:网络
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 ha

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 UIImageView large as the UIView frame and set its image property
  • 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

0

精彩评论

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