colorWithPatternImage 与.UIImageView [英] colorWithPatternImage Vs. UIImageView

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

问题描述

如果我只是想要 UIView 的背景图像,使用哪个更好?我可以使用任何一种方法来完成此操作,但哪种方法更有效?我的直觉是使用 UIViewcolorWithPaternImage 比使用 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 的性能.这是使用内置 colorWithPatternImageCGContextDrawTiledImage 的一个很好的高性能替代方案.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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