美文网首页
setEdgesForExtendedLayout

setEdgesForExtendedLayout

作者: 王zuozuo | 来源:发表于2017-03-17 10:42 被阅读185次

在iOS 7中,苹果引入了一个新的属性,叫做[UIViewController setEdgesForExtendedLayout:],它的默认值为UIRectEdgeAll
当容器是NavigationController时,默认的布局将从NavigationBar的顶部开始。这就是为什么所有的UI元素都往上漂移了44pt。
为了做适配,可以这样写:

if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }

如果对setEdgesForExtendedLayout有反应,则说明是iOS 7以上版本,默认UIRectEdgeAll,UI元素会往上漂移,需要设置回UIRectEdgeNone

相关文章

网友评论

      本文标题:setEdgesForExtendedLayout

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