UIViewController+PresentationStyle.m 1.1 KB

1234567891011121314151617181920212223242526272829
  1. //
  2. // UIViewController+PresentationStyle.m
  3. // xike
  4. //
  5. // Created by 翟玉磊 on 2017/9/29.
  6. // Copyright © 2017年 翟玉磊. All rights reserved.
  7. //
  8. #import "UIViewController+PresentationStyle.h"
  9. @implementation UIViewController (PresentationStyle)
  10. + (void)load {
  11. Method originAddObserverMethod = class_getInstanceMethod(self, @selector(presentViewController:animated:completion:));
  12. Method swizzledAddObserverMethod = class_getInstanceMethod(self, @selector(xike_presentViewController:animated:completion:));
  13. method_exchangeImplementations(originAddObserverMethod, swizzledAddObserverMethod);
  14. }
  15. - (void)xike_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
  16. if (@available(iOS 13.0, *)) {
  17. viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
  18. [self xike_presentViewController:viewControllerToPresent animated:flag completion:completion];
  19. } else {
  20. [self xike_presentViewController:viewControllerToPresent animated:flag completion:completion];
  21. }
  22. }
  23. @end