👔AdaptiveHStack
SwiftUI ⟩ Layout ⟩ Adaptive Layout ⟩ Size Classes ⟩
⬆️ 需要: 👔 AdaptiveHStack
struct ContentView: View {
@State private var isCompact = true
let text = """
For simplicity's sake, we will focus on conditions based on the horizontal space available: the same concepts can also be applied for vertical space.
"""
var body: some View {
Toggle("is compact", isOn: $isCompact)
.padding()
Spacer()
// 👔 AdaptiveHStack
AdaptiveHStack(threshold: isCompact, alignment: .top) {
// RoundedRectangle
RoundedRectangle(cornerRadius: 16)
.fill(Color.pink)
.frame(maxHeight: 300)
// VStack
VStack {
Text("Title")
.bold()
.font(.title)
Text(text)
.fixedSize(horizontal: false, vertical: true)
}
}
}
}⬆️ 需要: 👔 AdaptiveHStack
Last updated
Was this helpful?