Which is better to use if I simply want a background image for a UIView? I can accomplish this with either method, but which is more efficient? My hunch is that using a UIView with colorWithPaternImage is more efficient than using a UIImageView. I’ll be using this for each row in a UITableView. Thanks! Matt
Which is better to use if I simply want a background image for a
Share
Completely disagree with boreas. There can be significant differences using
colorWithPatternImagevs other strategies depending on your requirements. For example, if you are using aUIScrollView, usingcolorWithPatternImagewon’t allow the image to scroll. It also generally depends on how large your view is because there is some tradeoff in performance vs memory footprint for different tiling strategies.Check out WWDC 2010 session 104 which discusses tiling performance using
CATiledLayer. This is a good high-performance alternative to using either the built-incolorWithPatternImageorCGContextDrawTiledImage.If your requirement is simply to display a single 320×480 static image, then there won’t be any significant differences in the various strategies, but if your requirements are more complex then there certainly are.