iOS 编程全局解决模态弹出不全屏问题

利用runtime的特性,创建一个UIViewController的分类,然后pch文件导入

#import 

NS_ASSUME_NONNULL_BEGIN

@interface UIViewController (PModel)

@end

NS_ASSUME_NONNULL_END
#import "UIViewController+PModel.h"
#import 

@implementation UIViewController (PModel)

+(void)load{
       Method m1 = class_getInstanceMethod([self class], @selector(presentViewController:animated:completion:));
       Method m2 = class_getInstanceMethod([self class], @selector(p_presentViewController:animated:completion:));
       method_exchangeImplementations(m1, m2);
}

- (void)p_presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion{
    viewControllerToPresent.modalPresentationStyle =  UIModalPresentationFullScreen;
    [self p_presentViewController:viewControllerToPresent animated:flag completion:completion];
}

@end

你可能感兴趣的:(iOS 编程全局解决模态弹出不全屏问题)