UIWindow+JXSafeArea.m 737 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // UIWindow+JXSafeArea.m
  3. // JXCategoryView
  4. //
  5. // Created by jiaxin on 2018/9/29.
  6. // Copyright © 2018 jiaxin. All rights reserved.
  7. //
  8. #import "UIWindow+JXSafeArea.h"
  9. @implementation UIWindow (JXSafeArea)
  10. - (UIEdgeInsets)jx_layoutInsets {
  11. if (@available(iOS 11.0, *)) {
  12. UIEdgeInsets safeAreaInsets = self.safeAreaInsets;
  13. if (safeAreaInsets.bottom > 0) {
  14. //参考文章:https://mp.weixin.qq.com/s/Ik2zBox3_w0jwfVuQUJAUw
  15. return safeAreaInsets;
  16. }
  17. return UIEdgeInsetsMake(20, 0, 0, 0);
  18. }
  19. return UIEdgeInsetsMake(20, 0, 0, 0);
  20. }
  21. - (CGFloat)jx_navigationHeight {
  22. CGFloat statusBarHeight = [self jx_layoutInsets].top;
  23. return statusBarHeight + 44;
  24. }
  25. @end