UITextView의 isScrollEnabled 가 false일 때 intrinsicContentSize가 활성화 됩니다.
자세히 봅시다.
- textView를 생성해서 isScrollEnabled를 true 로 주면

(-1.0, -1.0) 이 출력됩니다.
swift에서는 intrinsicContentSize 가 없을 때 (-1, -1)의 값을 가집니다.
(항상 -1, -1을 가지는지는 모르겠으나 UIView에서도 값이 없을 때도 -1, -1을 가집니다.)
- 이번엔 isScrollEnabled 가 false 로 주고 출력해보면

(10.0, 52.0) 이 출력됩니다.
intrinsicContentSize 가 생겼습니다.
다시 정리를 하면, isScrollEnabled를 false로 설정하면 UITextView의 intrinsicContentSize가 활성화됩니다.
'UIKit' 카테고리의 다른 글
| UICollectionViewHeader with Dynamic Height (0) | 2023.09.25 |
|---|---|
| UIImageView를 Image 크기에 맞추기 [Swift] (0) | 2023.08.26 |
| cell의 이벤트 에러 [Swift] (0) | 2023.08.21 |
| addGestureRecognizer와 addTarget 차이 [Swift] (0) | 2023.08.21 |
| Firebase currentUser 에러 해결방법 in iOS Swift (0) | 2023.08.10 |