Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Observable
- ios
- 스위프트
- 리펙토링
- UITextView
- clean architecture
- swift documentation
- Xcode
- 리팩토링
- 리펙터링
- uiscrollview
- map
- Clean Code
- Refactoring
- 클린 코드
- RxCocoa
- uitableview
- MVVM
- Human interface guide
- 애니메이션
- collectionview
- Protocol
- SWIFT
- swiftUI
- rxswift
- ribs
- tableView
- HIG
- UICollectionView
- combine
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - swift] setContentHuggingPriority 사용 시 주의사항 (containerView와 contentView) 본문
iOS 응용 (swift)
[iOS - swift] setContentHuggingPriority 사용 시 주의사항 (containerView와 contentView)
jake-kim 2023. 9. 27. 02:06setContentHuggingPriority 개념
- 뷰가 고유 크기보다 커지는 것을 방지하기위해 우선 순위를 설정하는것
- cf) setContentCompressionResistancePriority: 뷰가 고유 크기보다 작게 되는것을 방지하기위해 우선 순위를 설정하는것
* 구체적인 개념은 이전 포스팅 글 참고
setContentHuggingPriority 주의사항
- containerView와 이 안에 있는 label이 있을 때, containerView의 hugging 값을 높게해주어도 안에 있는 label의 hugging값을 조절해주지 않는이상 적용되지 않으므로 주의
ex) 왼쪽, 중앙, 오른쪽 세 개의 뷰가 있을때,
중간에 있는 뷰의 hugging값을 높여서 길어지지 않도록 하고 싶은 경우?
- 중간에 있는 뷰의 hugging값만 높이면 적용 x
- 중간에 있는 뷰의 안에 있는 label의 hugging값을 높여야 적용 o
뷰에만 적용한 경우) 효과 x
centerView.setContentHuggingPriority(.required, for: .horizontal)
뷰 안에 있는 label에 적용한 경우) 효과 o
centerView.label.setContentHuggingPriority(.required, for: .horizontal)
* 전체 코드: https://github.com/JK0369/ExHugging
'iOS 응용 (swift)' 카테고리의 다른 글
Comments