标签:
// 事件传递给subview - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { CGPoint subviewP = [self convertPoint:point toView:_subview]; if ([_subview pointInside:subviewP withEvent:event]) { return _subview; }else { return [super hitTest:point withEvent:event]; } } // 手指移动 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:self]; CGPoint pre = [touch previousLocationInView:self]; CGFloat offsetX = location.x - pre.x; CGFloat offsetY = location.y - pre.y; CGPoint center = self.center; center.x += offsetX; center.y += offsetY; self.transform = CGAffineTransformTranslate(self.transform, offsetX, offsetY); }
标签:
原文地址:http://www.cnblogs.com/songxing10000/p/4520615.html