[ios autolayout] simple stackview 애플의 Auto layout guide에 나오는 simple stackView를 만들어 보겠습니다. 1 뷰컨트롤러에 수직스택뷰를 놓고 그 안에 차례대로 레이블, 이미지뷰, 버튼을 놓습니다. 2 그리고 스택뷰를 슈퍼뷰에 꽉차게 제약을 걸어줍니다. 그럼 아래와 같이 됩니다 왜 이렇게 됐을까요? - 제약 구조를 보면 4개의 각 변들이 safe area에 딱 붙는 걸 볼 수 있습니다.safeArea는 ios11부터 도입 된 것으로 뷰들이 상태바나 툴바 같은 영역을 침범하는 것을 방지 해줍니다. - stackView에 Alignment와 Distribution 이 Fill입니다.Alignment가 fill이면 StackView axis의 수직 방향으로 ..
What is the StackView스택뷰는 여러 뷰(스택뷰포함)들을 쌓아가는 뷰입니다. 스택뷰는 주요속성에 따라서 뷰를 쌓아갑니다. 주요속성에는 4가지가 있습니다. 1. axis : 뷰들을 쌓는 방향 - 가로 - 세로 2. aligment : 뷰들을 정렬 ( axis의 수직방향으로 적용 ) - horizontal axis 일 때는 : 수직방향으로 fill, top, center, bottom, first & last baseline - vertical axis 일 때는 : 수평방향으로 fill, leading, center, trailing 3. spacing : 뷰들간의 간격을 나타내는 속성 - CGFloat, 음수 양수 다 가능 - 음수로 할 경우 뷰가 겹침( 나중에 생성된 뷰가 위로 덮는 형식)..
[iOS Autolayout] Why stackViews first, constraints later Stack views provide an easy way to leverage the power of Auto Layout without introducing the complexity of constraints. In general, use stack views to manage as much of your layout as possible. Resort to creating constraints only when you cannot achieve your goals with stack views alone. The following recipes show how you can use stack vie..
iOS AutoLayout - What다양한 iOS 기기 화면에 유연하게 대응하기 위해 만들어 졌습니다. - HowSeven Commandments of AutoLayout And Guiding Principles of AutoLayout - from Udacity's AutoLayout Lecture - Guiding Principles of AutoLayout 1. stackViews first, constraints later 2. start small, or not at all 3. work from the inside out 4. Trust the simulator only 5. Don't panic - Seven Commandments of AutoLayout 1. Tweak The prope..