MINRYUL
류링류링
MINRYUL
전체 방문자
오늘
어제
  • 분류 전체보기
    • Swift
      • 학습
    • iOS
      • Toy-Project
      • 학습
      • Metal
    • CS
    • TIL

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • Existential type
  • BDD
  • RxCocoa
  • RxTest
  • dynamic frameworkm
  • WWDC 2024
  • configuration_bulid_dir
  • Any
  • RxSwift
  • WWDC
  • Existential any
  • Protocol
  • static framework
  • tuist
  • ViewStore
  • TableView Cell
  • TDD
  • RxNimble
  • opaque type
  • ios
  • Clean Architecture
  • METAL
  • some
  • Custom Calendar
  • AttributeText
  • CollectionView Cell
  • demangle
  • collectionView
  • Swift
  • urlsession

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
MINRYUL

류링류링

iOS/학습

translatesAutoresizingMaskIntoConstraints

2022. 2. 13. 15:24

translatesAutoresizingMaskIntoConstraints


 View에 AutoLayout을 코드로 작성할 경우 작성한 View의 translatesAutoresizingMaskIntoConstraints을 false로 만들어줘야 제대로 layout이 잡히게 된다. 항상 당연하다고 생각해 작성했는데, 왜 이 설정이 false로 되어야 제대로 layout이 잡히는지 알아보진 않은 것 같아 찾아보게 되었다.

 

A Boolean value that determines whether the view’s autoresizing mask is translated into Auto Layout constraints.

 apple 공식 문서에는 autoresizing mask를 auto layout constraints로 변환할 것인지 묻고 있다. Discussion에 따르면 코드로 작성한 뷰에 대해서는 기본값으로 true가 할당되어 있고, Interface Builder에서는 시스템이 자동으로 이 속성을 false로 만든다. 

 

 autoresizing 이란 autoresizing mask를 사용해서, superview가 커지거나 줄어듦에 따라 subview의 위치를 조정하는 방법을 말한다. 즉, autoresizingmask 설정 값에 따라서 subView들에 superview에 따라서 커지거나, 따라붙는 등의 속성을 정의할 수 있다(FlexibleWidth, FlexibleHeight, FlexibleRightMargin, FlexibleLeftMargin). 따라서 subview의 크기에 관여하므로 이와 동일한 기능인 autolayout을 같이 사용하게 된다면 충돌이 일어날 수 있고, 화면에 view가 제대로 보이지 않게 되는 것이다. 여담으로 이 autoresizing mask를 사용해서 뷰를 구성하게 되면 flexible 한 UI를 구축하기 어렵기 때문에 autolayout이 나온 것이라 한다.

 

 

 

 

Apple Developer Documentation

 

developer.apple.com

 

 

Apple Developer Documentation

 

developer.apple.com

'iOS > 학습' 카테고리의 다른 글

iOS View 에서의 init 함수들  (0) 2022.05.08
iOS RxDataSource로 Custom Xib CalendarView 만들기  (0) 2022.05.07
iOS에서의 Frame vs Bounds  (0) 2022.04.24
Storyboard 에서 Generic Type 의존성 주입하기  (0) 2022.03.20
Diffable DataSource Infinite Scroll  (0) 2022.01.24
    'iOS/학습' 카테고리의 다른 글
    • iOS RxDataSource로 Custom Xib CalendarView 만들기
    • iOS에서의 Frame vs Bounds
    • Storyboard 에서 Generic Type 의존성 주입하기
    • Diffable DataSource Infinite Scroll
    MINRYUL
    MINRYUL
    열심히 살자

    티스토리툴바