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/
  • 相关阅读:
    bzoj 1017 魔兽地图DotR
    poj 1322 chocolate
    bzoj 1045 糖果传递
    poj 3067 japan
    timus 1109 Conference(二分图匹配)
    URAL 1205 By the Underground or by Foot?(SPFA)
    URAL 1242 Werewolf(DFS)
    timus 1033 Labyrinth(BFS)
    URAL 1208 Legendary Teams Contest(DFS)
    URAL 1930 Ivan's Car(BFS)
  • 原文地址:https://www.cnblogs.com/liuw-flexi/p/12162273.html
Copyright © 2011-2022 走看看