如何解决ScrollView +自定义视图+ ContextMenu动画故障-SwiftUI
是否有解决方法来修复这些动画故障? Glitch video
- 滚动动画出现故障
- 视图消失不到一秒钟的那个
视图语义为:
TabView {
NavigationView {
ScrollView {
VStack {
ForEach(){
MyCustomView()
.contextMenu()
MyCustomView在下面,如果有人想对其进行测试:
struct CardVew: View {
var title: String
var description: String
var name: String
var task: String
var done: Bool
let tapVibration = UIImpactFeedbackGenerator(style: .light)
@State var details = false
var body: some View {
ZStack(alignment: .leading) {
RoundedRectangle(cornerRadius: 15)
.foregroundColor(Color("cardGray"))
.opacity(0.24)
VStack(alignment: .leading,spacing: .zero) {
titleBlock
descriptionBlock
bottomBlock
}
.padding([.leading,.trailing],20)
.padding(.bottom,15)
.padding(.top,24)
}
.padding([.leading,12)
.sheet(isPresented: $details) {
CardSheetView(
title: title,description: description,task: task,name: name
)
}
.onTapGesture {
tapVibration.impactOccurred()
details = true
}
.onAppear {
tapVibration.prepare()
}
}
private var titleBlock: some View {
HStack(alignment: .top) {
Text(title)
.font(.system(size: 22,weight: .bold))
.fixedSize(horizontal: false,vertical: true)
.frame(width: 244,alignment: .leading)
.padding(.bottom,4)
if done {
Spacer()
Image("done")
.opacity(0.8)
}
}
}
private var bottomBlock: some View {
HStack(alignment: .bottom) {
HStack(alignment: .center) {
Image(systemName: "calendar")
Text("22.09")
}
Spacer()
Text(name)
.multilineTextAlignment(.trailing)
.opacity(0.6)
.font(.footnote)
.frame(width: 211,alignment: .trailing)
}
}
private var descriptionBlock: some View {
Text(description)
.opacity(0.8)
.fixedSize(horizontal: false,vertical: true)
.frame(width: 247,alignment: .leading)
.padding(.bottom,38)
}
}
我试图排除所有动画,图纸和任何可能导致这种行为的东西,但没有成功
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。