All scrollviews(which Form
has built on) and shapes(which Circle
is) are greedy in layout priority. They don't have inner limitations so if there's available space whey gonna take it
Spacer
is greedy too, but it has lower priority then other greedy views
That's why in your case Form
and Circle
are splitting available space 50% to 50%
You need to restrict both their height to make it work.
VStack {
Circle().foregroundColor(.yellow).overlay(VStack {
Text("Example")
}).foregroundColor(.primary)
.frame(height: UIScreen.main.bounds.width)
Spacer()
Form {
TextField("test", text: $a)
TextField("test2", text: $b)
}.frame(height: 150)
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…