在自定义转换中闪烁,ios7

时间:2014-02-13 05:17:13

标签: ios viewcontroller

我使用此代码:

    CATransition *transition = [[CATransition alloc]init];
    transition.duration = 0.3;
    transition.type = kCATransitionMoveIn;
    transition.subtype= kCATransitionFromLeft;
    //transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
    [self.navigationController.view.layer addAnimation:transition forKey:kCATransactionCompletionBlock];

在视线右侧获得视觉眨眼。如果我使用kCATransitionFromRight,我会在左边眨眼。我在模拟器和设备上测试过。那是错的?

2 个答案:

答案 0 :(得分:0)

使用下面的代码并按照下面的说明进行操作

  CATransition *navTransition = [CATransition animation];
    navTransition.duration = 0.65;
    navTransition.timingFunction = [CAMediaTimingFunction 
          functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [navTransition setType:kCATransitionReveal];
    [navTransition setSubtype:kCATransitionFromRight];
    [view.navigationController.navigationBar.layer 
          addAnimation:navTransition forKey:nil];

这是最好的方式:

UINavigationControllerDelegate创建UINavigationController。您将听到通过navigationController:willShowViewController:animated:之一的委托方法将新视图推送/弹出到导航堆栈上。在适当的委托方法中,您可以在自定义UIViewController上设置属性,以便它知道在viewWillAppear等中使用哪个动画。

答案 1 :(得分:0)

如果部署目标是7.0,请使用UINavigationControllerDelegate自定义推/动画。

它有点复杂,但它非常强大。无论你想象什么,你都可以与这些代表一起做。

- (id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
                      interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController NS_AVAILABLE_IOS(7_0);

- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                               animationControllerForOperation:(UINavigationControllerOperation)operation
                                            fromViewController:(UIViewController *)fromVC
                                              toViewController:(UIViewController *)toVC  NS_AVAILABLE_IOS(7_0);