[iOS_study] Autolayout 재정리
iOS

[iOS_study] Autolayout 재정리

728x90

Auto Layout

iphone 6,7,8은 같은 사이즈
https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions

Constraints


Add New Constraints > 0 0 0 0 > 빨간 선 클릭 > Add 4 Constraints

  • View
    • AppBreweryBackground
    • Constraints
      • AppBreweryBackground.trailing = trailing

AppBreweryBackground.trailing의 superview는 AppBreweryBackground
AppBreweryBackground의 superview는 View

  • Constraints에 있는 파일 클릭하기
    • trailing edge 오른쪽, landscape로 봤을 때
      Second Item: Safe.Area.trailing 조건(홈버튼 때문에)

      Second Item: Superview.Trailing

Alignment and Pinning

Align> Horizontally in Container 체크
Align> Vertically in Container 체크

pinning은 containing view에서 예를 들어 30pt만큼 떨어진 거리를 나타낸다

Working with Containers and Subviews

(view에 넣어서 로고를 정리했을 때 사용)

element를 view에 embed in 하는 세가지 방법

  1. uiview라고 검색해서 빈 view를 추가
  2. element 2개를 클릭한 상태에서
    Editor> Embed in> View
  3. element를 선택한 상태에서 View 클릭

StackViews

(수직이나 수평하게 요소들을 정렬할 때 사용)

subviews에 레이아웃주기
subviews를 command키로 모두 선택한 후에 stackviews에 추가해주고
stackviews를 superview에 대해 constraints를 준다.

Axis: Vertical
Distribution: Fill Equally

연습

 

  1. element를 클릭해 stack view에 넣는다
  2. 생성한 stack view를 모두 클릭한 후 constraints를 준다
  3. 0 . = 해결방법
    . =를 stack view에 넣는다
  4. 검정색 화면인 0에 indent를 주는 방법
    embeded in View한 후 0 20 0 20 constraints를 준다
728x90