Check out the code first:
UIGraphicsBeginImageContext(self.view.frame.size);
contextRef=UIGraphicsGetCurrentContext();
CGContextSetLineCap(contextRef, kCGLineCapRound);
CGContextSetLineWidth(contextRef, brushWidth);
CGContextSetRGBStrokeColor(contextRef, 1.0, 1.0, 1.0, 1.0);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef glowColor = CGColorCreate( colorSpace, colorValues );
CGContextSetShadowWithColor( contextRef,CGSizeMake( 0.0, 0.0 ), 100.0f, glowColor );
CGContextBeginPath(contextRef);
while (beginY<ensdY) {
CGContextMoveToPoint(contextRef, beginX, beginY);
CGContextAddLineToPoint(contextRef,nextX,nextY);
beginX=nextX;beginY=nextY;
nextY=nextY+10;
if (arc4random()%3==0) {
nextX=nextX+arc4random()%10;
}
else {
nextX=nextX-arc4random()%10;
}
}
CGContextStrokePath(contextRef);
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
This code is called regularly.
Everything is fine in the simulator, but when I installed it on the iPhone, it becomes slow. I find it for CGContextSetShadowWithColor, but I donโt know why.
source
share