Performance issue of drawing and changing UIView gradient background color
in iOS
I am trying to implement a simple UIView with 3 colors radial gradient.
I have achieve this by using CGContextDrawRadialGradient in drawRect.
However I need to change the gradient colors from time to time based on
touch movements. What I did is to generate all possible gradient color
sets (288) and put them in to array and use it when I need them.
In my UIView I implemented this method to change the gradient:
- (void) setGradient:(CGGradientRef)gradient withRadius:(CGFloat)radius
{
_gradient = gradient;
_radius = radius;
[self setNeedsDisplay];
}
It works as expected, but the performance is really low. Am I doing this
in a wrong way?
No comments:
Post a Comment