Iphone 如何同时翻转两个视图?

Iphone 如何同时翻转两个视图?,iphone,objective-c,animation,view,flip,Iphone,Objective C,Animation,View,Flip,我尝试在一个屏幕上点击一个按钮来翻转两个视图,也就是说,我希望同时拥有多个动画(例如:iPhone音乐播放器,其中按钮和视图同时翻转) p、 我不想一个接一个地设置视图的动画,它应该一起完成 编辑 这是我使用的代码,请帮我解决 [UIView beginAnimations:nil context:nil]; [UIView animateWithDuration:0.8 animations:^{ if (viewDisplay) { [fareView

我尝试在一个屏幕上点击一个按钮来翻转两个视图,也就是说,我希望同时拥有多个动画(例如:iPhone音乐播放器,其中按钮和视图同时翻转)

p、 我不想一个接一个地设置视图的动画,它应该一起完成

编辑

这是我使用的代码,请帮我解决

[UIView beginAnimations:nil context:nil];
[UIView animateWithDuration:0.8 animations:^{

    if (viewDisplay) 

    {

        [fareView removeFromSuperview];

        [containerView addSubview:mapView];

        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];

        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:buttonView cache:YES];

        viewDisplay = FALSE;

        swapLabel.text = @"Fare View";

        [mapOrFare setImage:[UIImage imageNamed:@"original_icon.png"] forState:UIControlStateNormal];

    }

    else

    {

        [mapView removeFromSuperview];

        [containerView addSubview:fareView];

        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:containerView cache:YES];

        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:buttonView cache:YES];

        viewDisplay = TRUE;

        swapLabel.text = @"Map View";

        [mapOrFare setImage:[UIImage imageNamed:@"Map.png"] forState:UIControlStateNormal];

    }

}];

[UIView commitAnimations];

只需使用块动画,它应该没有问题的工作

[UIView animateWithDuration:myDuration
    animations:^{
        <animation 1 code>;
        <animation 2 code>;
}];
[UIView animateWithDuration:myDuration
动画:^{
;
;
}];

只需使用块动画,就可以正常工作

[UIView animateWithDuration:myDuration
    animations:^{
        <animation 1 code>;
        <animation 2 code>;
}];
[UIView animateWithDuration:myDuration
动画:^{
;
;
}];

假设
bgView1
bgView2
是要翻转的视图,如下所示;你应该能够把动画师的代码一个接一个地放进去,一切都会好的。请参见下面的示例

-(void)flipViews {

    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:bgView1 cache:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];

    [bgView1 exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    [UIView commitAnimations];


    context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:bgView2 cache:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];

    [bgView2 exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    [UIView commitAnimations];

}

假设
bgView1
bgView2
是要翻转的视图,如下所示;你应该能够把动画师的代码一个接一个地放进去,一切都会好的。请参见下面的示例

-(void)flipViews {

    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:bgView1 cache:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];

    [bgView1 exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    [UIView commitAnimations];


    context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:bgView2 cache:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];

    [bgView2 exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    [UIView commitAnimations];

}

我尝试使用[UIView beginAnimation….]设置两个子视图的动画。[UIView commitAnimation]块,但只有一个视图设置了动画。另一个只是出现了。我尝试使用[UIView beginAnimation….]设置两个子视图的动画。[UIView commitAnimation]块,但只有一个视图设置了动画。另一个简单地出现了。没有用,因为动画代码是关键。动画代码对于这个代码示例是什么样子的?没有用,因为动画代码是关键。动画代码对于这个代码示例是什么样子的??