如何解决在SwiftUI中创建自定义alertSheet
Swift 5.x iOS 13/14
尝试构建自定义操作表,并弄不清楚为什么当我告诉它仅从底部滑动时,它为什么会从左侧滑动然后向上滑动,或者至少我以为是我要的。
import SwiftUI
struct ContentView: View {
@State private var showingCustomSheet = false
var body: some View {
ZStack {
Button(action: {
self.showingCustomSheet.toggle()
}) {
Text("Fire")
.font(.largeTitle)
.foregroundColor(Color.red)
}
if showingCustomSheet {
CustomAlertSheet(showingCustomSheet: $showingCustomSheet)
}
}
}
}
struct CustomAlertSheet: View {
@Binding var showingCustomSheet: Bool
@State var showEscape = false
var body: some View {
VStack {
Spacer().onAppear {
withAnimation(.linear(duration: 2)) {
showEscape.toggle()
}
}
if showEscape {
Rectangle()
.fill(Color.red)
.frame(width: 256,height: 128)
.transition(.move(edge: .bottom))
.animation(.default)
}
}
}
}
解决方法
这是一个解决方案-删除了多余的内容和一些小的修复程序...经过Xcode 12 / iOS 14测试。
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
true<input type='radio' name='FirstSetName' value='true' />
false<input type='radio' name='FirstSetName' value='false' />
<div>
second 1<input type='radio' name='SecondSetName' value='2.1' style='display:none;' />
second 2<input type='radio' name='SecondSetName' value='2.2' style='display:none;' />
</div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。