LoginSignup
0
0

StackViewを比率で並べる

Posted at

はじめに

StackViewの中に3つのViewがあり、それらを高さ1:1:2の比率で配置したいときに、StoryBoard上でのやり方を知らなかったので共有します。

Screenshot 2024-06-13 at 10.33.53.png

方法

1. まずStackViewのAttributes InspectorのDistributionを”Fill”にする

Screenshot 2024-06-13 at 10.42.18.png

2. 次に、ctrlキーを押しながら1 Viewと2 Viewを選択し、”Equal Heights”を選択する

Screenshot 2024-06-13 at 10.49.27.png

同様に、1 Viewと3 Viewもctrlキーを押しながら選択し、”Equal Heights”を選択する

Screenshot 2024-06-13 at 10.50.24.png

3. 追加されたConstraintsの中の1 View.height = 3 View.heightを選択し、Attributes InspectorのMultiplierを1:2にする

Screenshot 2024-06-13 at 10.58.25.png

これにより、1 View : 2 View : 3 View = 1 : 1 : 2の状態を作ることができます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0