翻页效果的转页动画

类似书上例子:     按键触发按钮switchViews操作

 

- (IBAction)switchViews:(id)sender {
    [UIView beginAnimations:@"View Flip" context:nil]; 
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    
    if (self.yellowViewController.view.superview == nil) {
        if (self.yellowViewController == nil) {
            self.yellowViewController =
            [[BIDYellowViewController alloc] initWithNibName:@"YellowView"
                                                      bundle:nil];
        }
        [UIView setAnimationTransition:
         UIViewAnimationTransitionFlipFromRight
                               forView:self.view cache:YES];        
        
        [self.blueViewController.view removeFromSuperview];
        [self.view insertSubview:self.yellowViewController.view atIndex:0];
    } else {
        if (self.blueViewController == nil) {
            self.blueViewController =
            [[BIDBlueViewController alloc] initWithNibName:@"BlueView"
                                                    bundle:nil];
        }
        [UIView setAnimationTransition:
         UIViewAnimationTransitionFlipFromLeft
                               forView:self.view cache:YES];
        
        [self.yellowViewController.view removeFromSuperview];
        [self.view insertSubview:self.blueViewController.view atIndex:0];
    }
    [UIView commitAnimations];
}

 

#以下为转换动画效果的核心代码 ,出现类似翻页效果的动画

[UIView beginAnimations:@"View Flip" context:nil];     //声明 ,@"XX"为标题
[UIView setAnimationDuration:1.25];                       //持续时间
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//设置动画曲线类型

 

[UIView setAnimationTransition:
         UIViewAnimationTransitionFlipFromRight
                               forView:self.view cache:YES];  //调用及翻转方向设置

 

[UIView setAnimationTransition:
         UIViewAnimationTransitionFlipFromLeft
                               forView:self.view cache:YES];

 

[UIView commitAnimations];  //调用commitAnimations使启动动画块到此为止的所有动作都会被制成动画

posted @ 2012-07-06 21:24  小、  阅读(370)  评论(0)    收藏  举报