Is there any way to add Activity View (Indicator) into SwiftUI Alert somewhere? I'm just curious because I haven't found any appropriate answer on such question. I need something like this:
我正在使用 iOS 14 SwiftUI Alert,其可选状态符合Identifiable
。
UIKit UIAlertController 中有一种方法可以将子视图添加到警报视图中。
有没有一些想法,提前谢谢。
我必须在应用程序中执行类似的操作,基本上使用本机 SwiftUI 是不可能的.alert
API。你可以
- 使用自定义
UIAlertController
- 制作一个满足您需求的自定义叠加层
因为我创造了自定义警报 https://github.com/divadretlaw/CustomAlert这样我就可以轻松地使用自定义内容发出警报。它本质上是在 SwiftUI 中重新创建警报并为其公开类似的 API。
.customAlert(isPresented: $alertShown) {
HStack(spacing: 16) {
ProgressView()
.progressViewStyle(.circular)
.tint(.blue)
Text("Processing...")
.font(.headline)
}
} actions: {
Button(role: .cancel) {
// Cancel Action
} label: {
Text("Cancel")
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)