|
|
@@ -10,17 +10,22 @@
|
|
|
#import "UIScrollView+MJExtension.h"
|
|
|
#import <objc/runtime.h>
|
|
|
|
|
|
-#define SYSTEM_VERSION_GREATER_NOT_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
|
|
|
-
|
|
|
#pragma clang diagnostic push
|
|
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
|
|
|
|
|
@implementation UIScrollView (MJExtension)
|
|
|
|
|
|
+static BOOL gt_ios_11_;
|
|
|
++ (void)load
|
|
|
+{
|
|
|
+ // 缓存判断值
|
|
|
+ gt_ios_11_ = [[[UIDevice currentDevice] systemVersion] compare:@"11.0" options:NSNumericSearch] != NSOrderedAscending;
|
|
|
+}
|
|
|
+
|
|
|
- (UIEdgeInsets)mj_inset
|
|
|
{
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) {
|
|
|
+ if (gt_ios_11_) {
|
|
|
return self.adjustedContentInset;
|
|
|
}
|
|
|
#endif
|
|
|
@@ -32,7 +37,7 @@ - (void)setMj_insetT:(CGFloat)mj_insetT
|
|
|
UIEdgeInsets inset = self.contentInset;
|
|
|
inset.top = mj_insetT;
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) {
|
|
|
+ if (gt_ios_11_) {
|
|
|
inset.top -= (self.adjustedContentInset.top - self.contentInset.top);
|
|
|
}
|
|
|
#endif
|
|
|
@@ -49,7 +54,7 @@ - (void)setMj_insetB:(CGFloat)mj_insetB
|
|
|
UIEdgeInsets inset = self.contentInset;
|
|
|
inset.bottom = mj_insetB;
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) {
|
|
|
+ if (gt_ios_11_) {
|
|
|
inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom);
|
|
|
}
|
|
|
#endif
|
|
|
@@ -66,7 +71,7 @@ - (void)setMj_insetL:(CGFloat)mj_insetL
|
|
|
UIEdgeInsets inset = self.contentInset;
|
|
|
inset.left = mj_insetL;
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) {
|
|
|
+ if (gt_ios_11_) {
|
|
|
inset.left -= (self.adjustedContentInset.left - self.contentInset.left);
|
|
|
}
|
|
|
#endif
|
|
|
@@ -83,7 +88,7 @@ - (void)setMj_insetR:(CGFloat)mj_insetR
|
|
|
UIEdgeInsets inset = self.contentInset;
|
|
|
inset.right = mj_insetR;
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) {
|
|
|
+ if (gt_ios_11_) {
|
|
|
inset.right -= (self.adjustedContentInset.right - self.contentInset.right);
|
|
|
}
|
|
|
#endif
|