iphone - 在立方体动画中切换两个 View Controller 的 View

标签 iphone ios animation

下面的代码实现了立方体动画中两个 View 之间的切换。

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];

但是,如果 View 不属于self.navigationController,如何在两个 View Controller 之间切换立方体动画,然后如何同时缩放当前 View Controller 的 View ?非常感谢

最佳答案

这对我有用:

-(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];
}

关于iphone - 在立方体动画中切换两个 View Controller 的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4559777/

相关文章:

iphone - UITextView 末尾的省略号

ios - 如何使用动态单元格获取 UITableView 中多个文本字段的值?

android - CSS3 动画不适用于 Android 4.2

ios - 收到适用于 IOS 的 Opencv 库的错误

ios - 是否允许指向 Objective-C 数组的指针(通过桥接 header )?

ios - UIView 表面自定义转换/动画(如 'a water drop effect' )

jquery - 防止父元素上的 CSS 动画应用于子元素

iphone - 使用 drawRect 重绘

iphone - 导航栏消失时 UIStepper 不会向上移动

iOS 将 iPad 应用程序转换为通用应用程序不显示 iPhone 的 appIcon