티스토리 뷰
[iOS 오토레이아웃 ] Working with Constraints in Interface Builder
Rules of Thumb
- 절대로 view의 위치를 지정하지 마세요. frame, bounds, center를 가지고
- 가능하면 스택뷰를 쓰세요
- 제약조건은 가까운 뷰끼리 맺으세요
- 고정 height와 width 피하세요. 오토레이아웃의 장점이 사라질 수 있습니다. 정 필요하면 최소나 최대값만 사용
- view의 의미있는 이름을 지으세요
- 항상 leading과 trailing을 사용
semanticContentAtribute(ios), userInterfaceLayoutDirection(ox X)을 통해 뷰가 leading and trailing을 어떻게 해석할지 지정할 수 있음
- safe area 고려
https://developer.apple.com/documentation/uikit/uiview/positioning_content_relative_to_the_safe_area
- 코드로 할 때 translatesAtuoresizingMaskIntoConstraints false로 하기
- iOS와 OS X에서 layout 계산하는 게 다르기 때문에 꼼꼼히 보기
- 추가적으로 아래글도 보기
'iOS' 카테고리의 다른 글
[iOS 오토레이아웃 가이드] Debugging Auto Layout - Ambiguous Layouts (0) | 2018.08.06 |
---|---|
[iOS 오토레이아웃 가이드] Debugging Auto Layout - Unsatisfiable Layouts (0) | 2018.08.06 |
[iOS 오토레이아웃 ] 제약조건 구조 ( Anatomy of a Constraint ) (0) | 2018.08.05 |
[iOS 오토레이아웃 ] 제약조건 없이 오토레이아웃 만들기 (0) | 2018.08.03 |
[iOS 오토레이아웃 ] 오토레이아웃 이해하기 (0) | 2018.08.03 |