天天看點

push 自定義動畫

-(CATransition *)MyCAnimation1:(UIView *)viewNum upDown:(BOOL )boolUpDown{

            CATransition *animation = [CATransition animation];

            animation.delegate =self;

            animation.duration =0.5f ;

            animation.timingFunction = UIViewAnimationCurveEaseInOut;

            animation.fillMode = kCAFillModeForwards;

            animation.endProgress =1;

            animation.removedOnCompletion =NO;

            animation.type =@"pageCurl";//101

           if (boolUpDown) {

                animation.subtype = kCATransitionFromRight;

            }else{

                animation.subtype = kCATransitionFromLeft;

            }

           return animation;

        }

        //加載到UINavigationConroller上

        [self.navigationController.view.layer addAnimation:[self MyCAnimation1:self.view upDown:YES] forKey:@"animation"];

        //本身動畫要取消

       //推入

        [self.navigationControllerpushViewController:@"控制器對象" animated:NO];

       //傳回

        [self.navigationControllerpopViewControllerAnimated:NO];

- (IBAction)CustomPushview {  //自定義切換動畫效果
    CATransition *animation = [CATransition animation];
    [animation setDuration:3.3];
    [animation setType:kCATransitionFade]; //淡入淡出
    [animation setSubtype:kCATransitionFromLeft];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
    MapViewController *mapview = [[MapViewController alloc] initWithNibName:Nil bundle:NULL];
    [self.navigationController pushViewController:mapview animated:NO];
    [self.navigationController.view.layer addAnimation:animation forKey:nil]; 
    
}
           

其他的動畫效果可以自己去更改上面的一些動畫屬性和參數