import SwiftUI
struct ContentView: View {
@State var showingActionSheet = false
@State var backgroundColor = Color.white
var body: some View {
Text("Hello, World").frame(width: 300, height: 300).background(backgroundColor).onTapGesture {
showingActionSheet = true
}.actionSheet(isPresented: $showingActionSheet, content: {
ActionSheet(title: Text("Change background"), message: Text("Select a new color"),
buttons: [.default(Text("Red")){backgroundColor = .red},
.default(Text("Green")){backgroundColor = .green},
.default(Text("Blue")){backgroundColor = .blue},
.cancel()])
})
}
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交