[英]SwiftUI transition is not working properly
當視圖出現時,我試圖從底部邊緣過渡到頂部。
ZStack{
VStack {
.
.//other components
.
if self.modalShown {
HStack {
GeometryReader { geometry in
BottomSheetView(
isOpen: self.$modalShown,
maxHeight: geometry.size.height * 0.6
) {
ZStack(alignment: .bottom) {
FiltersView(hideControl: self.$modalShown)
.transition(.move(edge: .bottom))
}
.edgesIgnoringSafeArea(.bottom)
}
}
}
.accessibility(identifier: "modalFilterView")
}
}
問題是當這個視圖出現時,它會執行一種從 alpha 0 到 alpha 1 的轉換。 當視圖被關閉時,它不會執行任何轉換。
這種不良行為可能與 zIndex 相關嗎?
問題是過渡修飾符在錯誤的地方:
ZStack{
VStack {
.
.//other components
.
if self.modalShown {
HStack {
GeometryReader { geometry in
BottomSheetView(
isOpen: self.$modalShown,
maxHeight: geometry.size.height * 0.6
) {
ZStack(alignment: .bottom) {
FiltersView(hideControl: self.$modalShown)
}
.edgesIgnoringSafeArea(.bottom)
}
}
}
.transition(.move(edge: .bottom))
.accessibility(identifier: "modalFilterView")
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.