任何人都可以在这段代码中看到一些东西,让它在 iPhone 上运行得非常柔和,但在 iPad 上的视网膜和非视网膜上却又慢又不稳定/笨拙?关于如何加快 iPad 速度的任何想法?我只想让它基本上用手指绘画,控制画笔大小、不透明度和边缘(这就是为什么我有渐变,用于软边缘)
谢谢
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPointTemp = [touch locationInView:parentView.view];
CGPoint currentPoint = CGPointMake((currentPointTemp.x /imageScale)+ (posOffset.x/imageScale), (currentPointTemp.y /imageScale) + (posOffset.y/imageScale));
currentPoint.y -= 10;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(drawImage.frame.size.width, drawImage.frame.size.height), NO, 0);
[drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetAlpha(UIGraphicsGetCurrentContext(), opacity);
CGContextBeginPath (UIGraphicsGetCurrentContext());
CGContextAddArc(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y, glamzyDelegate.brushSize, 0, 6.28318531, 0);
CGContextClosePath (UIGraphicsGetCurrentContext());
CGContextClip(UIGraphicsGetCurrentContext());
CGPoint myStartPoint, myEndPoint;
CGFloat myStartRadius, myEndRadius;
myStartPoint.x = lastPoint.x;
myStartPoint.y = lastPoint.y;
myEndPoint.x = lastPoint.x;
myEndPoint.y = lastPoint.y;
myStartRadius = 0;
myEndRadius = glamzyDelegate.brushSize;
CGContextDrawRadialGradient(UIGraphicsGetCurrentContext(), gradient, myStartPoint, myStartRadius, myEndPoint, myEndRadius, kCGGradientDrawsAfterEndLocation);
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}