概要
Content Hugging Priority
とContent Compression Resistance Priority
は主にUIStackView
で使うもので、
制約と組み合わせると(こいつ自身も制約といえば制約だけど)
UIStackView
内で大きさが可変する可能性のあるUIをうまく管理できる
詳しい内容は後で追記
・親Viewやデバイスの大きさが中のコンテンツ(=子View)(priority
を適用するView)
より大きい
Content Compression Resistance Priority
→低い方が縮む
より小さい
Content Hugging Priority
→低い方が余白で広がって埋める
参考記事
・Auto Layoutで固有サイズを使いこなそう | Money Forward Engineers' Blog
・StackViewの優先度 Content Hugging PriorityとContent Compression Resistance Priority
・今更だけど正しく身につけよう『Content Hugging Priority』と『Content Compression Resistance Priority』 - Takahiro Octopress Blog
・【Swift】Compression Registance PriorityとContent Hugging Priorityをコードから考える - Qiita