gpt4 book ai didi

objective-c - 恢复 iOS7 之前的 UINavigationController pushViewController 动画

转载 作者:IT老高 更新时间:2023-10-28 11:46:10 28 4
gpt4 key购买 nike

所以。刚开始将我的 IOS 代码转换到 IOS7,遇到了一些问题。

我有一个 UINavigationController,它有子 ViewControllers,我正在使用 pushViewController 来显示下一个 View 。要使用一组图像创建视差动画,如果自定义 UINavigationController 以动画一组 UIImageViews 并且我的子 ViewControllers 都有一个 self.backgroundColor = [ UIColor clearColor],透明度。

从 iOS7 开始,UINavController 对其子 vc 的动画方式进行了更新,通过部分移动当前 View Controller 并在顶部推送新的 View Controller ,我的视差动画看起来很糟糕。我看到之前的 VC 移动了一下,然后消失了。有什么办法可以恢复以前的 UINavigationController pushViewController 动画?我似乎在代码中找不到这个。

WelcomeLoginViewController* welcomeLoginViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"WelcomeLogin"];
[self.navigationController pushViewController:welcomeLoginViewController animated:YES];

甚至尝试使用:

    [UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.navigationController pushViewController:welcomeLoginViewController animated:NO];
[UIView setAnimationTransition:<specific_animation_form> forView:self.navigationController.view cache:NO];
}];

有人知道吗?

最佳答案

我设法通过为 UINavigationController 创建一个类别来解决新的过渡类型。在我的情况下,我需要将其恢复为旧的过渡样式,因为我有透明的 viewControllers 可以在静态背景上滑动。

  • UINavigationController+Retro.h

    @interface UINavigationController (Retro)

    - (void)pushViewControllerRetro:(UIViewController *)viewController;
    - (void)popViewControllerRetro;

    @end
  • UINavigationController+Retro.m

    #import "UINavigationController+Retro.h"

    @implementation UINavigationController (Retro)

    - (void)pushViewControllerRetro:(UIViewController *)viewController {
    CATransition *transition = [CATransition animation];
    transition.duration = 0.25;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromRight;
    [self.view.layer addAnimation:transition forKey:nil];

    [self pushViewController:viewController animated:NO];
    }

    - (void)popViewControllerRetro {
    CATransition *transition = [CATransition animation];
    transition.duration = 0.25;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromLeft;
    [self.view.layer addAnimation:transition forKey:nil];

    [self popViewControllerAnimated:NO];
    }

    @end

关于objective-c - 恢复 iOS7 之前的 UINavigationController pushViewController 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18867248/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com