如何在目标c中向视图添加多个动画?

时间:2013-03-07 19:55:42

标签: iphone objective-c ios6

我想在视图中添加多个动画。我只能添加一个,...我不想连接

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kAnimationDuration];
//self.square.bounds = CGRectMake(0, 0, self.square.bounds.size.height, 200);
//self.transform = CGAffineTransformMakeScale(2, 1);


CGAffineTransform scaleTrans1 = CGAffineTransformMakeScale(2, 1);

self.transform = scaleTrans1;
[UIView commitAnimations];

2 个答案:

答案 0 :(得分:2)

您可以使用UIView中的animateWithDuration(在任何变体中),只要您尝试设置动画的属性实际上是可动画的(查看UIView / Animations)。

例如:

[UIView animateWithDuration:1.0f
animations: ^ {
    self.square.bounds = CGRectMake(0, 0, self.square.bounds.size.height, 200);
    self.transform = CGAffineTransformMakeScale(2, 1);
}];

希望它有所帮助!

答案 1 :(得分:0)

我确实喜欢这个及其工作

- (void)drawRect:(CGRect)rect
{    
    [UIView animateWithDuration:4.0f animations:^{
        self.transform = CGAffineTransformMakeScale(2, 1);
    } completion:^(BOOL finished){
        [UIView animateWithDuration:4.0f animations:^{
           self.transform = CGAffineTransformMakeScale(0.75, 1);
        } completion:^(BOOL finished){
            [UIView animateWithDuration:4.0f animations:^{
              self.transform = CGAffineTransformMakeScale(2, 1);  
            } completion:^(BOOL finished) {
                [UIView animateWithDuration:4.0f animations:^{
                    self.transform = CGAffineTransformMakeScale(0.75, 1);
                }];
            }];
        }];
    }];


}