본문 바로가기

전체 글

(36)
UIView - bounds and frame 2탄 우와! 2탄! 퇴근 후 간단하게 작성하는 글이니 편안한 문체 이해해주시면 감사하겠습니다. UIView - bounds UIView - frame UIView의 프로퍼티 중 하나인 bounds와 frame은 뷰의 위치와 크기를 나타내는 속성이다. CGRect 타입이며 origin과 size로 이루어져 있다. origin은 위치를 나타내며 size는 말 그대로 크기를 나타낸다. size는 bounds와 frame 모두 동일하다. 그런데 재밌는 점은 frame의 공식문서 설명을 보면 // frame Setting this property changes the point specified by the center property and changes the size in the bounds rectangle a..
UICollectionView - invalidateLayout() invaildateLayout() 직역하면 현재 레이아웃을 무효화하고 레이아웃 업데이트를 트리거합니다. 기능은 레이아웃 업데이트 사이클에 새롭게 레이아웃을 업데이트 하는 메서드다. 비슷한(?) 기능으로는 reloadData()가 있지만 invaildateLayout은 기존 데이터는 건들이지 않고 레이아웃만 업데이트하는 메서드다. 또한 레이아웃 업데이트를 '트리거' 하는거라 동일한 코드 블럭 안에서 여러번 호출 할 수 있다. 단, iOS 13에서 디바이스를 가로 세로 모드 전환 할 때 메서드를 호출하면 안먹힐 수 있다(?) 간단한 해결 방법으론 VC의 라이프 사이클 중 viewWillTransition(to:with:) 에서 invaildateLayout()를 호출하면 잘 먹는다.
Dynamic Color - 다크모드 천천히 알아보기 위해 편하게 작성하겠습니다. WWDC19 - Implementing Dark Mode on iOS - WWDC19 - Videos - Apple Developer Hear from the UIKit engineering team about the principles and concepts that anchor Dark Mode on iOS. Get introduced to the principles of... developer.apple.com 앱의 모든 View 및 ViewController에는 traitCollection이 있으며 이를 통해 뷰의 모양을 결정하는데 도움을 준다. Dynamic Color를 사용하면 자동으로 light 혹은 dark mode의 색상이 정해진다. 자동으로 ..