2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【SwiftUI】Spacerの最小サイズが0にならない問題

Last updated at Posted at 2021-08-20

#課題
VStackやHStack内でSpacerがある時に、ビュー一杯一杯にオブジェクトを詰め込んだ時に、Spacerの大きさが0にならないで残ってしまう

VStack {
    ZStack{}.frame(height: 50)
    Spacer() // 微妙に細く残る
    ZStack{}.frame(height: 50)
}
.frame(height: 100)

#解決法

「minLength: 0」を設定する

VStack {
    ZStack{}.frame(height: 50)
    Spacer(minLength: 0)
    ZStack{}.frame(height: 50)
}
.frame(height: 100)
2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?