colorWithPatternImage Vs.的UIImageView [英] colorWithPatternImage Vs. UIImageView

查看:213
本文介绍了colorWithPatternImage Vs.的UIImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我只想要 UIView 的背景图片,哪个更好?我可以用任何一种方法来实现这一点,但哪种方法更有效?我的预感是使用 UIView colorWithPaternImage 比使用 UIImageView更有效。我将在 UITableView 中的每一行使用它。谢谢!马特

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

推荐答案

完全不同意哈纳斯。根据您的要求,使用 colorWithPatternImage 与其他策略可能存在显着差异。例如,如果您使用 UIScrollView ,则使用 colorWithPatternImage 将不允许图像滚动。它通常还取决于您的视图有多大,因为不同的平铺策略在性能与内存占用方面存在一些权衡。

Completely disagree with boreas. There can be significant differences using colorWithPatternImage vs other strategies depending on your requirements. For example, if you are using a UIScrollView, using colorWithPatternImage won'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.

查看 WWDC 2010会议104 ,使用 CATiledLayer 讨论平铺性能。这是使用内置 colorWithPatternImage CGContextDrawTiledImage 的一个很好的高性能替代方案。

Check out WWDC 2010 session 104 which discusses tiling performance using CATiledLayer. This is a good high-performance alternative to using either the built-in colorWithPatternImage or CGContextDrawTiledImage.

如果您的要求只是显示单个320x480静态图像,那么各种策略不会有任何显着差异,但如果您的要求更复杂,那么肯定会有。

If your requirement is simply to display a single 320x480 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.

这篇关于colorWithPatternImage Vs.的UIImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆