我有一个UIView
属性UIImage
。我正在屏蔽该图像并将其添加到UIView
。一旦我将蒙版剪裁到图像上,我的手势就不再起作用了。
掩蔽代码:
CGContextRef ctx = UIGraphicsGetCurrentContext();
... // Creating mask
CGContextClip(ctx);
[self.image drawInRect:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)];
CGContextDrawPath(ctx, kCGPathStroke);
手势代码:
- (void)move:(UIPanGestureRecognizer*)gesture {
CGPoint translation = [gesture translationInView:self.superview];
CGRect currentFrame = self.frame;
currentFrame.origin.x = self.frame.origin.x + translation.x;
currentFrame.origin.y = self.frame.origin.y + translation.y;
self.frame = currentFrame;
[gesture setTranslation:CGPointZero inView:self.superview];
}
如果我删除此行:CGContextClip(ctx);
手势效果很好。任何建议都将不胜感激。