码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发之--全局解决模态弹出不全屏展示问题

时间:2020-02-17 12:42:07      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:style   imp   解决   rto   res   ios   nullable   pch   全局   

利用tuntime的特性,创建一个UIViewController的类别,然后再pch文件里面调用即可,代码如下:

.h

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIViewController (SKPVCModel)

@end

NS_ASSUME_NONNULL_END

.m

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

@implementation UIViewController (SKPVCModel)

+(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

这样的话,就可以了!

仅做记录!

iOS开发之--全局解决模态弹出不全屏展示问题

标签:style   imp   解决   rto   res   ios   nullable   pch   全局   

原文地址:https://www.cnblogs.com/hero11223/p/12320751.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!