Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Force iOS <13 modal behaviour in iOS 13 apps
@import UIKit;
@interface UIViewController (iOS13)
#import "UIViewController+iOS13.h"
@import ObjectiveC.runtime;
@implementation UIViewController (iOS13)
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(modalPresentationStyle);
SEL swizzledSelector = @selector(custom_modalPresentationStyle);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
method_exchangeImplementations(originalMethod, swizzledMethod);
- (UIModalPresentationStyle)custom_modalPresentationStyle {
if (@available(iOS 13.0, *)) {
UIModalPresentationStyle style = [[self valueForKey:@"_modalPresentationStyle"] integerValue];
return style == UIModalPresentationAutomatic ?
UIModalPresentationFullScreen :
return [self custom_modalPresentationStyle];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.