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/
  • 相关阅读:
    进程及进程调度
    加强版水王:找出出现次数刚好是一半的数字
    寻找最小的k个数(四种方法)
    Count Primes
    深入理解计算机系统结构——并发编程
    深入理解计算机系统——系统级I/O
    深入理解计算机系统结构——虚拟存储器
    老生常谈:关于undo表空间的使用率
    OSW 快速安装部署
    Oracle参数设置之set与reset的实际案例
  • 原文地址:https://www.cnblogs.com/liuw-flexi/p/12162273.html
Copyright © 2011-2022 走看看