zoukankan      html  css  js  c++  java
  • iOS13 present VC方法

    更新iOS 13之后,发现我们工程模态展示的视图默认是非全屏的。经过百度一番(百度就够了)。因为苹果在iOS13改了默认的样式。在iOS13前,该值默认为UIModalPresentationFullScreen。而在 iOS13 中默认值变为了UIModalPresentationAutomatic。所以就出现了类似sheet 的非全屏样式。如果考虑到全工程一一在present前加一句vc.modalPresentationStyle = UIModalPresentationFullScreen; 麻烦, 可以hook全局处理。
    #import <UIKit/UIKit.h>
    
    NS_ASSUME_NONNULL_BEGIN
    
    @interface UIViewController (LGModel)
    -(void)lg_presentViewController:(UIViewController*)viewControllerToPresent animated:(BOOL)flag completion:(void(^)(void))complete;
    @end
    
    NS_ASSUME_NONNULL_END
    #import "UIViewController+LGModel.h"
    
    #import <objc/runtime.h>
    
    @implementation UIViewController (LGModel)
    
    +(void)load{
        [super load];
        
        SEL exchangeSel = @selector(lg_presentViewController: animated: completion:);
        SEL originalSel = @selector(presentViewController: animated: completion:);
        method_exchangeImplementations(class_getInstanceMethod(self.class, originalSel), class_getInstanceMethod(self.class, exchangeSel));
    }
    
    -(void)lg_presentViewController:(UIViewController*)viewControllerToPresent animated:(BOOL)flag completion:(void(^)(void))completion{
        viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
        [self lg_presentViewController:viewControllerToPresent animated:flag completion:completion];
    }
    
    @end


    作者:Virusboo
    链接:https://www.jianshu.com/p/f3be643e66e3
    来源:简书
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
    此文仅为鄙人学习笔记之用,朋友你来了,如有不明白或者建议又或者想给我指点一二,请私信我。liuw_flexi@163.com/QQ群:582039935. 我的gitHub: (学习代码都在gitHub) https://github.com/nwgdegitHub/
  • 相关阅读:
    CentOS7 设置软件镜像源
    让树莓派自动上报IP地址到邮箱,二代B
    给树莓派安装看门狗的两种方法,二代B
    树莓派(Raspberry Pi)USB无线网卡自动连接,二代B
    升级MAC OX上的Python到3.4
    http 返回码 405 解决方案之一
    CentOS 6.4 SSH 免密码登录
    SVN的Hooks功能--强制添加注释
    PHP开发中,让var_dump调试函数输出更美观 ^_^#
    CentOS 6.4 命令行 安装 VMware Tools
  • 原文地址:https://www.cnblogs.com/liuw-flexi/p/12162273.html
Copyright © 2011-2022 走看看