我正在旋转一个轮子,其中包含各种子视图(UIImageViews 和 UIButtons)但是当我要求它显示每个子视图的每个中心时,它每次都给我相同的值。
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *allTouches = [event allTouches];
int len = [allTouches count]-1;
UITouch *touch =[[allTouches allObjects] objectAtIndex:len];
CGPoint location = [touch locationInView:[self superview]];
float theAngle = atan2( location.y-self.center.y, location.x-self.center.x );
totalRadians = theAngle;
[self rotateImage:theAngle];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
}
-(void) rotateImage:(float)angleRadians{
self.transform = CGAffineTransformMakeRotation(angleRadians);
CATransform3D rotatedTransform = self.layer.transform;
self.layer.transform = rotatedTransform;
int count = 0;
for (UIView *subview in self.subviews)
{
count++;
//these values are always the same
NSLog(@"%i %f %f", count, subview.center.x, subview.center.y);
}
}
有人可以告诉我为什么即使在旋转并放置在不同的位置之后,这些值总是相同的?
谢谢!