zoukankan      html  css  js  c++  java
  • 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;
        }];
    }
  • 相关阅读:
    C#使用反射得到属性然后创建xml文档
    android多种方式实现异步加载图片
    Linux小结
    ThinkPHP5小结
    redis小结
    Android AIDL使用详解
    广播接收器 broadcast sendOrderedBroadcast android
    Android之ContentProvider总结
    ContentProvider实例整理
    Android网络编程之Socket&Http
  • 原文地址:https://www.cnblogs.com/benbenzhu/p/3571629.html
Copyright © 2011-2022 走看看