我有一个 UIView,我希望用户能够在屏幕上拖动。
-(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
CGPoint pt = [[touches anyObject] locationInView:self];
CGPoint center = self.center;
CGFloat adjustmentX = pt.x - startLocation.x;
CGFloat adjustmentY = pt.y - startLocation.y;
center.x += adjustmentX;
center.y += adjustmentY;
[self setCenter:center];
}
工作完美,直到我对视图应用如下变换:
self.transform = CGAffineTransformMakeRotation(....);
但是,一旦应用了变换,拖动 UIView 会导致视图以指数螺旋效果移动。
我假设我必须对 touchesMoved 方法中的旋转进行更正,但到目前为止,所有尝试都让我望而却步。