[英]How to remove title from actionSheet in SwiftUI
Just like the question asks, how do I remove the title from the action sheet below?就像问题问的那样,如何从下面的操作表中删除标题? I'm using iOS 14, don't want to upgrade to
SwiftUI
3. There's no initializer for the actionSheet with a titleVisibility parameter or anything like that.我正在使用 iOS 14,不想升级到
SwiftUI
3. 没有带有 titleVisibility 参数或类似参数的 actionSheet 的初始化程序。 I also tried 'nil' as you can see below, but it's not optional.正如您在下面看到的,我也尝试了“nil”,但它不是可选的。 Not sure how to make the title disappear.
不确定如何使标题消失。
@State var showOptions: Bool = false
Button(action: {
showOptions = true
}, label: {
}).actionSheet(isPresented: $showOptions) {
ActionSheet(
title: nil,
buttons: [
.cancel(),
.default(Text("Red")) {
print("x")
},
.default(Text("Green")) {
print("y")
},
.default(Text("Blue")) {
print("z")
},
]
)
}
ConfirmationDialog can be used to show Action Sheet behaviour without title. ConfirmationDialog可用于显示没有标题的操作表行为。
struct ContentView: View {
@State private var showingOptions = false
@State private var selection = "None"
var body: some View {
VStack {
Text(selection)
Button("Confirm paint color") {
showingOptions = true
}
.confirmationDialog("", isPresented: $showingOptions, titleVisibility: .automatic) {
ForEach(["Red", "Green", "Blue"], id: \.self) { color in
Button(color) {
selection = color
}
}
}
}.frame(width:300, height: 600)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.