Skip to content

Instantly share code, notes, and snippets.

@CibelePaulinoAndrade
Last active July 26, 2018 14:10
Show Gist options
  • Save CibelePaulinoAndrade/e0081eb19c42bc581c3cdc8faafb73a6 to your computer and use it in GitHub Desktop.
Save CibelePaulinoAndrade/e0081eb19c42bc581c3cdc8faafb73a6 to your computer and use it in GitHub Desktop.
extension ViewController: UIDragInteractionDelegate {
//Método usado para pegar um item
func dragInteraction(_ interaction: UIDragInteraction, itemsForBeginning session: UIDragSession) -> [UIDragItem] {
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 {
let imageToDrag = imageView.image
let provider = NSItemProvider(object: imageToDrag!)
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