|
|
@@ -10,12 +10,15 @@
|
|
|
#import "UIScrollView+MJExtension.h"
|
|
|
#import <objc/runtime.h>
|
|
|
|
|
|
+#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
|
|
|
+
|
|
|
+
|
|
|
@implementation UIScrollView (MJExtension)
|
|
|
|
|
|
- (UIEdgeInsets)mj_inset
|
|
|
{
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if(@available(iOS 11.0, *)){
|
|
|
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
|
|
|
return self.adjustedContentInset;
|
|
|
}
|
|
|
#endif
|
|
|
@@ -27,7 +30,7 @@ - (void)setMj_insetT:(CGFloat)mj_insetT
|
|
|
UIEdgeInsets inset = self.contentInset;
|
|
|
inset.top = mj_insetT;
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if(@available(iOS 11.0, *)){
|
|
|
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
|
|
|
inset.top -= (self.adjustedContentInset.top - self.contentInset.top);
|
|
|
}
|
|
|
#endif
|
|
|
@@ -44,7 +47,7 @@ - (void)setMj_insetB:(CGFloat)mj_insetB
|
|
|
UIEdgeInsets inset = self.contentInset;
|
|
|
inset.bottom = mj_insetB;
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if(@available(iOS 11.0, *)){
|
|
|
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
|
|
|
inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom);
|
|
|
}
|
|
|
#endif
|
|
|
@@ -61,7 +64,7 @@ - (void)setMj_insetL:(CGFloat)mj_insetL
|
|
|
UIEdgeInsets inset = self.contentInset;
|
|
|
inset.left = mj_insetL;
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if(@available(iOS 11.0, *)){
|
|
|
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
|
|
|
inset.left -= (self.adjustedContentInset.left - self.contentInset.left);
|
|
|
}
|
|
|
#endif
|
|
|
@@ -78,7 +81,7 @@ - (void)setMj_insetR:(CGFloat)mj_insetR
|
|
|
UIEdgeInsets inset = self.contentInset;
|
|
|
inset.right = mj_insetR;
|
|
|
#ifdef __IPHONE_11_0
|
|
|
- if(@available(iOS 11.0, *)){
|
|
|
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
|
|
|
inset.right -= (self.adjustedContentInset.right - self.contentInset.right);
|
|
|
}
|
|
|
#endif
|