DrawRect: speed and CGContextDrawRadialGradient (super slow?)

I am having problems with my UIViewsubclass function drawRect:. I use CGContextDrawRadialGradient()in him and he. When the user drags my UIView, he tried his best to keep up with the gradient.

Using Time Profiler, I see that literally> 98% of my time is spent in my subclass drawRect: method.

First: will using a static gradient image be faster? Second: is there a way to speed this up? Can I cache the gradient? it does not change much, but the paths around it and its intersections change when dragging UIView.

If anyone knows a general guide on how to make methods drawRect:not suck all processor cycles, that would be great.

+3
source share
1 answer

I have the same problem. One solution is to apply a smaller gradient and scale it. The results are not perfect, but faster.

See also the ideas mentioned in this answer .

0
source

Source: https://habr.com/ru/post/1779922/


All Articles