切换两种显示控制器的视图中的立方体动画 [英] switch two view controller's view in a cube animation

查看:210
本文介绍了切换两种显示控制器的视图中的立方体动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

低于code实现两个视图之间切换在一个立方体的动画。

the code below implement the switch between two view in a cube animation .

UIViewController* viewCtrl = [[UIViewController alloc] init:book];

CATransition *transition = [CATransition animation];
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = @"cube";
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
self.navigationController.navigationBarHidden = NO;
[self.navigationController pushViewController:viewCtrl animated:YES];    

[viewCtrl release];

但是,如果认为不属于self.navigationController,怎么办立方体动画切换两种显示控制器之间,然后如何缩放当前视图控制器在同一时间的看法?非常感谢

but, if the view don't belong to self.navigationController, how to do switch in cube animation between two view controller, and then how to scale the current view controller's view in the same time? thanks very much

推荐答案

这为我工作:

-(IBAction)animate:(id)sender {
    NSLog(@"animate");

    CATransition *transition = [CATransition animation];
    transition.delegate = self;
    transition.duration = 0.8;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    NSString *types[4] = {@"cube", @"rippleEffect", @"cube", @"alignedCube"};
    NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromRight};

    transition.type = types[0];
    transition.subtype = subtypes[1];

    [self.view.layer addAnimation:transition forKey:nil];

    SecondView *_secondViewController = [[SecondView alloc]initWithNibName:@"secondView" bundle:nil];
    self.secondViewController = _secondViewController;
    _secondViewController = nil;

    [[[self view] layer] addAnimation: transition forKey: nil];
    [[self view] addSubview: [self.secondViewController view]];
}

-(void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag{
    [self.view release];
}

这篇关于切换两种显示控制器的视图中的立方体动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆