1、利用runtime方法交换机制 适配iOS11--contentInsetAdjustmentBehavior
#import "UIScrollView+PYExtension.h"
#import
@implementation UIScrollView (PYExtension)
+ (void)load {
Method systemMethod = class_getInstanceMethod(self, @selector(initWithFrame:));
Method customMethod = class_getInstanceMethod(self, @selector(m_initWithFrame:));
method_exchangeImplementations(systemMethod, customMethod);
}
- (instancetype)m_initWithFrame:(CGRect)frame {
UIScrollView *scrollV = [self m_initWithFrame:frame];
if (@available(iOS 11.0, *)) {
scrollV.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
return scrollV;
}
@end
//网上有篇相似文字 是同一公司同事;
网友评论