automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout的区别

automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout的区别_第1张图片
automaticallyAdjustsScrollViewInsets.png
automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout的区别_第2张图片
default.png
automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout的区别_第3张图片
extendedLyoutIncludesOpaqueBars.png
automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout的区别_第4张图片
isTranslucent.png
automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout的区别_第5张图片
edgesForExtendedLayout.png
automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout的区别_第6张图片
这张图说明了一切

观察中间红色按钮的位置,可以了解到self.view.frame的起始位置不同

btn.center = self.view.center

创建scrollView的代码,frame = self.view.bounds

scrollView = UIScrollView()
scrollView.frame = self.view.bounds
scrollView.backgroundColor = UIColor.lightGrayColor()
scrollView.contentSize = CGSize(width: 0, height: 1000)
view.addSubview(scrollView)

红色和蓝色视图的设置,注意红色视图的frame.origin.y

let redView = UIView()
redView.frame.origin = CGPoint(x: 10, y: scrollView.frame.size.height - 164)
redView.frame.size = CGSize(width: 100 , height: 100)
redView.backgroundColor = UIColor.redColor()
scrollView.addSubview(redView)
        
let blueView = UIView()
blueView.frame.origin = CGPoint(x: 10, y: 0)
blueView.frame.size = CGSize(width: 100 , height: 100)
blueView.backgroundColor = UIColor.blueColor()
scrollView.addSubview(blueView)

第一页是默认展示效果
第二页是自定义视图效果
第三页是滑动不经过navigationBar效果

另外下面有详细介绍的,最近比较忙,等笔者有时间再整理
http://www.myexception.cn/operating-system/1809934.html

你可能感兴趣的:(automaticallyAdjustsScrollViewInsets和edgesForExtendedLayout的区别)