1

我有一个 iOS 应用程序,可以让我通过触摸擦除图像。它在 iphone 上运行良好,但在 ipad air 上却落后很多。它在 iPhone 上使用约 40MB 的内存,但在 ipad 上使用约 200MB。有任何想法吗?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    lastTouch = [touch locationInView:self.backImageView];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    currentTouch = [touch locationInView:self.backImageView];


    CGPoint eraserPoint = CGPointMake(currentTouch.x - self.eraser.size.width/2, currentTouch.y - self.eraser.size.height/2);
    self.backImageView.image = [self eraseImageAtPoint:eraserPoint inImageView:self.backImageView fromEraser:self.eraser];


}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

}


- (UIImage *)eraseImageAtPoint: (CGPoint)point inImageView: (UIImageView *)imgView fromEraser: (UIImage *)eraser {

    UIGraphicsBeginImageContextWithOptions(imgView.frame.size, NO, 0.0f );
    [imgView.image drawInRect:CGRectMake(0, 0, imgView.frame.size.width, imgView.frame.size.height)];
    [eraser drawAtPoint:point blendMode:kCGBlendModeDestinationOut alpha:self.eraserSpeedSlider.value];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}
4

0 回答 0