delete green (+) icon when onInsert

I use .onInsert now.

I want to delete green (+) icon that displayed by default.

Is it possible?

  • Can you show a complete code example and a sample image showing the green (+) icon?

Add a Comment

Accepted Reply

I couldn't figure out how to change it with onInsert, but I did find out that DropProposal is involved. By implementing it with onDrop, I was able to successfully turn it off.

Replies

example code

struct ContentView: View {
  @State private var dragging: Ramen?
  @State private var ramens = [Ramen(name: "ramen", id: 0),
         Ramen(name: "ramen2", id: 1),
         Ramen(name: "ramen3", id: 2)]

  var body: some View {
    List {
      ForEach(ramens) { ramen in
        Image(ramen.name)
          .onDrag {
            self.dragging = ramen
            return NSItemProvider(object: String(ramen.id) as NSString)
          }
      }
      .onInsert(of: [.text], perform: insert)
    }
  }

  private func insert(index: Int, _: [NSItemProvider]) {
    ...
  }
}
  • Thanks for showing the code. (If you could show the sample screen shot, it was better.) But I cannot find any green (+) icon running your code on iOS 15.0 Simulator. Can you clarify how I can see it?

Add a Comment

when dragging

  • Thanks for adding the image and the description. But unfortunately, I do not know any ways to delete it. With easily understandable code and image, someone who knows how to do it (if possible) would find this thread more easily. Hope you can solve your issue soon.

Add a Comment

I couldn't figure out how to change it with onInsert, but I did find out that DropProposal is involved. By implementing it with onDrop, I was able to successfully turn it off.