UIScrollView contentInset 属性有什么用? [英] What's the UIScrollView contentInset property for?
本文介绍了UIScrollView contentInset 属性有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以向我解释 UIScrollView
实例中的 contentInset
属性的用途吗?也许提供一个例子?
Can someone explain to me what the contentInset
property in a UIScrollView
instance is used for? And maybe provide an example?
推荐答案
它设置内容视图和封闭滚动视图之间的插入距离.
It sets the distance of the inset between the content view and the enclosing scroll view.
Obj-C
aScrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 7.0);
Swift 5.0
aScrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 7.0)
这是一篇很好的 iOS 参考库文章滚动视图具有信息丰富的屏幕截图(图 1-3) - 我将在此处通过文本复制它:
Here's a good iOS Reference Library article on scroll views that has an informative screenshot (fig 1-3) - I'll replicate it via text here:
_|←_cW_→_|_↓_
| |
---------------
|content| ↑
↑ |content| contentInset.top
cH |content|
↓ |content| contentInset.bottom
|content| ↓
---------------
_|_______|___
↑
(cH = contentSize.height; cW = contentSize.width)
滚动视图包含内容视图以及指定内容插入提供的任何填充.
The scroll view encloses the content view plus whatever padding is provided by the specified content insets.
这篇关于UIScrollView contentInset 属性有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文