1

このコードで、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;
}
4

1 に答える 1

0

touch イベントで描画ルーチンを呼び出さないでください。

  1. ビューの drawrect メソッドをオーバーライドする必要があります
  2. タッチイベントで setneedsdisplay を呼び出す
于 2012-06-21T16:30:26.493 に答える