我有一个 UIImageView 对象,我用 frame 属性和 CFaffineTransformMakeRotate 旋转,然后我想用它的框架的移动原点来移动它,但是我的图像移动并奇怪地重塑了形状。
@implementation TimberView
(void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { // Retrieve the touch point CGPoint pt = [[touches anyObject] locationInView:self]; startLocation = pt; [[self superview] bringSubviewToFront:self]; }
(void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { // Move relative to the original touch point CGPoint pt = [[touches anyObject] locationInView:self]; CGRect frame = [self frame];
frame.origin.x += pt.x - startLocation.x; frame.origin.y += pt.y - startLocation.y; [self setFrame:frame]; }
TimberView 类是 UIImageView 的子类