我有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);
手势工作得很好。任何建议将不胜感激。