のカスタム部分だけを描画しようとしています(つまり、ユーザーがタッチした部分を明らかUIImageにしたい)のプロパティを使用して妥当な結果を得ています。UIImagemasklayer
私の次のようなものUIView:
UIBezierPath *maskPath = [UIBezierPath bezierPath];
[maskPath setLineWidth:10.0];
[maskPath moveToPoint:CGPointMake(10.0, 10.0)];
[maskPath addLineToPoint:CGPointMake(100.0, 100.0)];
CAShapeLayer *shapeMaskLayer = [CAShapeLayer layer];
shapeMaskLayer.path = maskPath.CGPath;
[self.layer setMask:shapeMaskLayer];
次にdrawRect、
- (void)drawRect:(CGRect)rect
{
[img drawInRect:rect];
}
できます。で定義された画像の部分を見ているだけですmaskPath。
しかし、それがこの問題への最善のアプローチだとは思えません。だから私の質問は: iOS SDK で画像のカスタム部分 (任意の形状) だけを描画する最良の方法は何でしょうか? .