Fork me on GitHub

UIview 如何防止第一次绕anchor point旋转时的跳动

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *touch = [touches anyObject];
CGPoint locationInView = [touch locationInView:self];
CGPoint locationInSuperview = [touch locationInView:self.superview];

self.layer.anchorPoint = CGPointMake(locationInView.x / self.frame.size.width, locationInView.y / self.frame.size.height);
self.center = locationInSuperview;
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *touch = [touches anyObject];
CGPoint locationInSuperview = [touch locationInView:self.superview];

self.center = locationInSuperview;
}

posted on 2012-03-06 15:01  pengyingh  阅读(408)  评论(0)    收藏  举报

导航