4
下面是上一个问题的后续步骤。我的代码下面通过缩放和旋转来为正方形设置动画。它通过进行旋转变换并向其添加缩放变换来完成此操作。这工作正常。完成后,它会调用throbReset
。我曾经有throbReset
只是将self's transform
设置为CGAffineTransformMakeScale
,这将会对其进行缩放,但也会将其取消。所以我尝试着从目前的transform
开始,并加入了不成比例的标准,但现在它没有做任何事情(可见)。无法撤消缩放变换而不撤消旋转变换
CGColorRef color = [[colorArray objectAtIndex:colorIndex] CGColor];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDidStopSelector:@selector(throbReset:context:)];
// [[self layer] setFillMode:kCAFillModeForwards]; // apparently not needed
CGAffineTransform xForm = CGAffineTransformMakeScale(2.0, 2.0);
xForm = CGAffineTransformRotate(xForm, M_PI/4);
[self setTransform:xForm];
[[self layer] setBackgroundColor:color];
[UIView commitAnimations];
}
- (void)throbReset:(NSString *)animationID context:(void*)context {
NSLog(@"-%@:%s fired", [self class], _cmd);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
CGAffineTransform xForm = [self transform];
xForm = CGAffineTransformScale(xForm, 1.0, 1.0);
[self setTransform:xForm];
[UIView commitAnimations];
}
因此,如果我刚刚将我的'transform'属性设置为'CGAffineTransformMakeScale(1.0,1.0)',它会不会回到原始大小?我猜不出'CGAffineTransformMakeScale'和'CGAffineTransformScale'之间的区别。我的意思是我理解这些论点是什么,但不是基础功能。 – Steve 2010-10-21 15:56:44
您对CGAffine函数调用中指定的变换操作相对较多,因此TransformScale会将输入相对于自身进行缩放。在这种情况下,您输入当前的变换,该变换的缩放比例为1:1。我不确定MakeScale的差异,也许它假设身份变换作为输入变换。 – Ben 2010-10-21 16:01:34