iOS MJRefresh適配ios11以及iPhoneX

陳世流年發表於2020-12-14

MJRefresh 是配iPhone異形曲面屏

找到

UIScrollView+MJExtension

然後在找到

- (void)setMj_insetT:(CGFloat)mj_insetT

然後將這方法改成下面樣子即可


- (void)setMj_insetT:(CGFloat)mj_insetT
{
    UIEdgeInsets inset = self.contentInset;
    inset.top = mj_insetT;
#ifdef __IPHONE_11_0
    if(@available(iOS 11.0, *)){
        inset.top -= (self.adjustedContentInset.top - self.contentInset.top);
    }
#endif
    self.contentInset = inset;
}

這樣就完成了適配

相關文章