Skip to content

Instantly share code, notes, and snippets.

@CibelePaulinoAndrade
Last active July 26, 2018 14:39
Show Gist options
  • Save CibelePaulinoAndrade/c5c619292d8dfcb604df84856b343fe3 to your computer and use it in GitHub Desktop.
Save CibelePaulinoAndrade/c5c619292d8dfcb604df84856b343fe3 to your computer and use it in GitHub Desktop.
func dragInteraction(_ interaction: UIDragInteraction, itemsForAddingTo session: UIDragSession, withTouchAt point: CGPoint) -> [UIDragItem] {
// Adicionar novos itens a seleção
if let textView = interaction.view as? UITextView {
let textToDrag = textView.text
let provider = NSItemProvider(object: textToDrag! as NSString)
let item = UIDragItem(itemProvider: provider)
return [item]
}
else if let imageView = interaction.view as? UIImageView {
guard let image = imageView.image else { return [] }
let provider = NSItemProvider(object: image)
let item = UIDragItem(itemProvider: provider)
return [item]
}
return []
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment