问题描述
如果我只是想要 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
推荐答案
完全不同意boreas.根据您的要求,使用 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 与.UIImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)