如何在单个animateWithDuration调用期间缩放和旋转

时间:2013-01-20 23:21:48

标签: iphone ios objective-c animation uikit

我使用以下代码为UIView制作动画。这样做效果很好,但是我如何同时将它设置为动画比例,理想情况下我会喜欢它在旋转时缩小到0。

[UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
                 animations:^(void) {
                     recognizer.view.transform = CGAffineTransformMakeRotation(DegreesToRadians(540));
                     recognizer.view.backgroundColor = [[UIColor alloc] initWithRed:220.0/255.0 green:220.0/255.0 blue:220.0/255.0 alpha:1.0];   
                 }];

1 个答案:

答案 0 :(得分:11)

只需使用CGAffineTransformConcat方法即可。尝试:

[UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
                 animations:^(void) {
                     recognizer.view.transform = CGAffineTransformConcat(CGAffineTransformMakeRotation(DegreesToRadians(540)), CGAffineTransformMakeScale(1.0, 1.0));
                     recognizer.view.backgroundColor = [[UIColor alloc] initWithRed:220.0/255.0 green:220.0/255.0 blue:220.0/255.0 alpha:1.0];   
                 }];

希望有帮助!