runtime方法全局解决iOS13模态试图不全屏显示问题

给UIViewController添加分类SKPModel

1.分类的.h文件

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIViewController (SKPModel)

@end

NS_ASSUME_NONNULL_END

2.分类的.m文件

#import "UIViewController+SKPModel.h"
#import <objc/runtime.h>



@implementation UIViewController (SKPModel)


+(void)load{
       Method m1 = class_getInstanceMethod([self class], @selector(presentViewController:animated:completion:));
       Method m2 = class_getInstanceMethod([self class], @selector(skp_presentViewController:animated:completion:));
       method_exchangeImplementations(m1, m2);
}
- (void)skp_presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion{
    viewControllerToPresent.modalPresentationStyle =  UIModalPresentationFullScreen;
    [self skp_presentViewController:viewControllerToPresent animated:flag completion:completion];
}
@end
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,590评论 0 3
  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 13,793评论 1 32
  • 闺蜜最近遇到了烦心事,找我来诉苦,原因是最近忙于一个大型活动,由于与领导的沟通不畅,加之工作出现纰漏,被领...
    荷语微光阅读 3,552评论 0 2
  • 1 情商,是这几年经久不衰的热门关键词。 其实不难理解,和情商低的人待在一块,太遭罪了,...
    lingshen阅读 3,954评论 0 0
  • 感赏儿子,出现笑脸的频率多了。 感赏儿子,中午陪我一起去吃饭,吃了孩子最喜欢的红焖鸡米饭,看着儿子吃的挺香,我也很...
    THY桃花颜阅读 1,150评论 0 0