私は基本的に、別の目的で iSteam/iFog alebit の非常に単純なバージョンに似たものを作成しようとしています。実際には、2 つのイメージがあり、1 つは主題のイメージで、もう 1 つは凝縮などのイメージです。次に、ユーザーが画面上で指を拭くと、一番上のレイヤーからそれが「切り取られ」、下のレイヤーが表示されます。これまでのところ、CoreGraphics とストロークを使用して画面に基本的な線を描くことができましたが、これを蒸気レイヤーのアルファ マスクとして使用する方法が見つかりません。
誰かが私に何を使うべきか、またはさらに良いサンプルコードについてアドバイスをくれたら、私は非常に感謝しています。これが私がこれまでに持っているものです:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
UIGraphicsBeginImageContext(self.view.frame.size);
CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[drawImage.image drawInRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, 36.0);
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextBeginPath(context);
CGContextMoveToPoint(context, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);
CGContextStrokePath(context);
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
}