• presentModalViewController方法,present一个透明的viewController,带动画效果


    //假设需要被present的控制器实例为controller,controller的背景色设置为clearColor
    UIViewController * rootcontroller = self.view.window.rootViewController; rootcontroller.modalPresentationStyle = UIModalPresentationCurrentContext;//进入的动画失效
    [rootcontroller presentViewController:controller animated:NO completion:
    ^{ rootcontroller.modalPresentationStyle = UIModalPresentationFullScreen; }]; controller.view.transform = CGAffineTransformMakeTranslation(0, controller.view.frame.size.height); [UIView animateWithDuration:0.35 animations:^{ controller.view.transform = CGAffineTransformMakeTranslation(0, 0); }];

     将其封装成Catrgory后,备用:

    - (void) presentTransparentController:(UIViewController *)controller withDuration:(CGFloat) duration {
        
        controller.view.backgroundColor = [UIColor clearColor];
        controller.view.transform = CGAffineTransformMakeTranslation(0, controller.view.frame.size.height);
        [UIView animateWithDuration:duration animations:^{
            controller.view.transform = CGAffineTransformMakeTranslation(0, 0);
        }];
        
        self.modalPresentationStyle = UIModalPresentationCurrentContext;//让进入的动画失效
        [self presentViewController:controller animated:NO completion:^{
            self.modalPresentationStyle = UIModalPresentationFullScreen;
        }];
    }
  • 相关阅读:
    GoLang设计模式15 策略模式
    GoLang设计模式18 适配器模式
    GoLang设计模式14 状态模式
    GoLang设计模式12 空对象模式
    GoLang设计模式19 桥接模式
    GoLang设计模式17 访客模式
    GoLang设计模式13 观察者模式
    GoLang设计模式16 模板方法模式
    Papervision3D材质
    Papervision3D基本原理
  • 原文地址:https://www.cnblogs.com/benbenzhu/p/3571629.html
Copyright © 2020-2023  润新知