Post

Replies

Boosts

Views

Activity

Reply to The behavior of onDrag and onDrop in iOS 18 is different from previous versions.
Ok, here is the snippet. import SwiftUI struct ContentView: View { @State var str: String = "Drag me" var body: some View { VStack(spacing: 100) { Text(str) .frame(width: 100, height: 100) .background(.blue) .onDrag { NSItemProvider(object: String(str) as NSString) } VStack { Text("Drop Here!") } .frame(width: 200, height: 200) .background(.red) .onDrop(of: [.text], delegate: MyDelegate()) } } } struct MyDelegate: DropDelegate { func performDrop(info: DropInfo) -> Bool { return true } } #Preview { ContentView() }
Sep ’24