美文网首页ios积累
ios11 UIScrollView和UITableView 适

ios11 UIScrollView和UITableView 适

作者: 凤鹃一鸣 | 来源:发表于2017-09-20 17:35 被阅读160次

在ios 11 系统中

当 UIScrollView,UICollectionView ,UITableView尺寸发生了改变了

设置一下它们ios11新属性

/* Configure the behavior of adjustedContentInset.

Default is UIScrollViewContentInsetAdjustmentAutomatic.

*/

@property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior API_AVAILABLE(ios(11.0),tvos(11.0));

// tableView适配ios11

if (@available(iOS 11.0, *)) {

        tableView.estimatedRowHeight = 0;

        tableView.estimatedSectionFooterHeight = 0;

        tableView.estimatedSectionHeaderHeight = 0;

        tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

    }

凡是Scrollview 及 Scrollview子类都会有适配问题,整个工程里可以一行代码解决问题:

// AppDelegate 进行全局设置

if(@available(iOS11.0, *)){

 [[UIScrollViewappearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];

 }

相关文章

网友评论

    本文标题:ios11 UIScrollView和UITableView 适

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