iOS11 系統為UIScrollView增加一個contentInsetAdjustmentBehavior屬性,默認為UIScrollViewContentInsetAdjustmentAutomatic,要想和iOS11之前顯示效果一樣的話,只需要寫一個分類在+ (void)load方法設置一下就好了
#import "UIScrollView+KJExtension.h"
@implementation UIScrollView (KJExtension)
+ (void)load {
NSLog(@"scrollView調用了load方法");
if (@available(iOS 11.0, *)){
[[self appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
}
@end
