美文网首页iOS10~最新系统适配相关
几行代码适配iOS11 scrollview及其子类

几行代码适配iOS11 scrollview及其子类

作者: angBiu | 来源:发表于2017-10-17 14:35 被阅读56次

在 appdelegate 添加

if (@available(iOS 11.0, *)) {
        [UIScrollView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        [UITableView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        [UICollectionView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        [UIWebView appearance].scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        //底下这三句是解决mjrefresh 上拉偏移的bug
        [UITableView appearance].estimatedRowHeight = 0;
        [UITableView appearance].estimatedSectionHeaderHeight = 0;
        [UITableView appearance].estimatedSectionFooterHeight = 0;
    } else {
        // Fallback on earlier versions
    }

相关文章

网友评论

    本文标题:几行代码适配iOS11 scrollview及其子类

    本文链接:https://www.haomeiwen.com/subject/fqjduxtx.html