티스토리 뷰
iOS
[iOS 오토레이아웃 Views with Intrinsic Content Size] Three Equal - Width Buttons
rhinoPHS 2018. 8. 2. 16:44from apple auto layout guide
[iOS 오토레이아웃 Views with Intrinsic Content Size] Three Equal - Width Buttons
전 예제(2018/08/02 - [iOS] - [iOS 오토레이아웃 Views with Intrinsic Content Size] Two Equal - Width Buttons)에서 버튼 하나가 추가 됐습니다.
View and Constraints
Short Button.Leading = Safe Area.Leading + 16
Medium Button.Leading = Short Button.Trailing + Standard
Long Button.Leading = Medium Button.Trailing + Standard
Long Button.Trailing = Safe Area. trailing + 16
Bottom Layout Guide.Top = Short Button.Bottom + 20.0
Bottom Layout Guide.Top = Medium Button.Bottom + 20.0
Bottom Layout Guide.Top = Long Button.Bottom + 20.0
Short Button.Width = Medium Button.Width
Short Button.Width = Long Button.Width
Atrributes
button의 크기를 보기 쉽게 button의 배경색을 줍니다. button의 타이틀 다르게 줘서 text가 width 영향을 안 미친다는 것을 확인해보세요
Discussion
전 예제와 비슷한 얘기를 합니다. intrinsic content size를 사용하면 적은 제약조건으로도 괜찮지만 사용하지 않는다면 제약조건이 더 필요합니다. 위치와 사이즈를 다 명확히 해야하기 때문이죠. Tip도 있네요. 3개 버튼을 다 선택한 다음 Pin버튼으로 Equal width를 한 번에 줄 수 있다고 합니다.