开发者

drawRect: speed and CGContextDrawRadialGradient (super slow?)

I'm having problems with my UIView subclass' drawRect: function. I use CGContextDrawRadialGradient() in it, and it. When the user drags my UIView it struggled to keep up if I include the gradient.

Using Time Profiler I see that literally > 98% of my time is spent in my subclass' drawRect开发者_如何学C: method.

First: would using a static image of a gradient be faster? Second: is there any way to speed this up? Can I cache the gradient somehow? it doesn't change much but paths around it and intersecting it do change as you drag the UIView.

If anybody knows of a general guide on how to make drawRect: methods not suck up all the cpu cycles, that would be awesome.


I'm having the same problem. One solution is to draw a smaller gradient and scale it up. The results is not pixel perfect, but faster.

See also the ideas mentioned in this answer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜