开发者

Using drawRect, setNeedsDisplay and layoutSubViews

Is there any ground rule for using methods like drawRect, setNeedsDisplay and layou开发者_高级运维tSubViews? I believe they adversely affect the app performance. Is there any preferred alternatives for these messages?


While this isn't an exact duplicate of this question, I believe my answer there still applies.

In summary, -drawRect: will redraw the content within a view, which is an expensive operation. Avoid redrawing if you can by layering content and moving or hiding those layers as needed.

However, these redraws typically will only have a significant performance impact if there are many of them done in rapid succession, like when trying to animate content. One-off redraws of static UI elements will not perceptively slow things down.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜