Last active
July 26, 2018 14:10
-
-
Save CibelePaulinoAndrade/e0081eb19c42bc581c3cdc8faafb73a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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