iOS

[iOS] Bounds와 Frame의 차이점

devharrry 2020. 1. 3. 21:35

 

UIView의 Instance Property 중 Frame 과 Bounds가 있는데 이 두개의 차이점에 대해서 알아보겠습니다. 

 

Frame

https://developer.apple.com/documentation/uikit/uiview/1622621-frame

 

frame - UIView | Apple Developer Documentation

The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.

developer.apple.com

SuperView의 좌표를 기준으로 View의 위치와 크기를 나타낸다. 

x, y 좌표를 변경하게 되면 자기 자신의 위치가 변경된다.

Bounds

https://developer.apple.com/documentation/uikit/uiview/1622580-bounds

 

bounds - UIView | Apple Developer Documentation

The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.

developer.apple.com

뷰의 위치와 크기를 자기 자신 뷰 안에서 위치와 크기를 나타낸다.

x, y 좌표를 변경하게 되면 자신을 포함한 하위뷰들 위치도 같이 옮겨집니다.