Skip to content

Instantly share code, notes, and snippets.

@dnnta
Created May 4, 2012 09:04
Show Gist options
  • Save dnnta/2593453 to your computer and use it in GitHub Desktop.
Save dnnta/2593453 to your computer and use it in GitHub Desktop.
contentInset contentSize和contentOffset区别
http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html
contentSize是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),
代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。
contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,
contentoffset就是(0 ,480),也就是y偏移了480
//与margin类似
contentInset是scrollview的contentview的顶点相对于scrollview的位置,例如你的contentInset = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示
_|←_cW_→_|_↓_
| |
---------------
|content| ↑
↑ |content| contentInset.top
cH |content|
↓ |content| contentInset.bottom
|content| ↓
---------------
_|_______|___
(cH = contentSize.height; cW = contentSize.width)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment