iOS

[iOS]contentInset, contentOffset

devharrry 2020. 2. 23. 19:49

contentInset

하위뷰 콘텐츠의 상하좌우로 안쪽 여백을 주는 것입니다. (바깥쪽 x) 

 

https://developer.apple.com/documentation/uikit/uiscrollview/1619406-contentinset

 

contentInset - UIScrollView | Apple Developer Documentation

Instance Property contentInset The custom distance that the content view is inset from the safe area or scroll view edges. DeclarationDiscussionUse this property to extend the space between your content and the edges of the content view. The unit of size i

developer.apple.com

예제

scrollView.contentInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)

 

contentOffset

Bounds의 Origin Point입니다. 즉 x, y좌표를 의미하는 것으로 ScrollView에서 스크롤과 동시에 ContentOffset이 변하는 것입니다. 

(ContentOffset이 변하면 스크롤됨)

 

https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset

 

contentOffset - UIScrollView | Apple Developer Documentation

Instance Property contentOffset The point at which the origin of the content view is offset from the origin of the scroll view. Declarationvar contentOffset: CGPoint { get set } Discussion

developer.apple.com

예제

scrollView.contentOffset = CGPoint(x: 0, y: 20)