티스토리 뷰

from apple auto layout guide

[iOS 오토레이아웃 Views with Intrinsic Content Size] Two Equal - Width Buttons



width가 같은 두 개의 버튼을 만드는 예제입니다. 전에 했던 예제에 비해 간단합니다. 







width Intrinsic Content Size를 고려하지 않아서 별로 좋지 않은 예제라고 생각됩니다. 그래서 예제로 넣었을 수 도 있겠습니다.



View and Constraints 


  1. Short Button.Leading = Safe Area.leading + 16

  2. Long Button.Leading = Short Button.Trailing + Standard

  3. Long Button.Trailing = Safe Area.Trailing + 16

  4. Bottom Layout Guide.Top = Short Button.Bottom + 20.0

  5. Bottom Layout Guide.Top = Long Button.Botton + 20.0

  6. Short Button.Width = Long Button.Width

Atrributes

button의 타이틀을 바꿔주시고, button의 크기를 보기 쉽게 button의 배경색을 줍니다.

Discussion

button에는 intrinsic content size가 있습니다. width는 고려하지 않지만 height는 고려합니다. 그래서 4,5번 두 개만 필요한 것이죠. 아래 글에서는 intrinsic content size가 없는 view를 가지고 했기 때문에 위아래 4개 필요했습니다. 비교하면 intrinsic content size가 어떻게 레이아웃에 영향을 끼치는지 알 수 있습니다.


반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함