最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

swift - How do you use SwiftUI's .onDrop(_: delegate:) view modifier with animation? - Stack Overflow

programmeradmin2浏览0评论

Consider a SwiftUI view that's using the .onDrop modifier:

struct Blah: View
{
    @State private var isDraggingActive: Bool

    var body: some View
    {
       ...
    }
    .onDrop(of: [.fileURL], isTargeted: $isDraggingActive.animation(.easeInOut(duration: 0.15)), perform: { providers in
            ...
        })
}

This lets our view nicely animate its state when a drag enters. Works great. But, if we need full control over validating the drag and use the delegate .onDrop method, instead, what is the right way to achieve the same animated updating of isDraggingActive?

struct Blah: View
{
    var dragDelegate = MyDragDelegate()
    @State private var isDraggingActive: Bool

    var body: some View
    {
       ...
    }
    .onDrop(of: [.fileURL], delegate: dragDelegate)   // How do we update the isDraggingActive state with animation here?
}
发布评论

评论列表(0)

  1. 暂无评论