Created
April 22, 2020 02:23
-
-
Save SunXiaoShan/0f4d7fee1a1cc7d8373a2a82e6285de8 to your computer and use it in GitHub Desktop.
This file contains 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
func setupCollectionView() { | |
self.collectionView.collectionViewLayout = columnLayout | |
self.collectionView.dataSource = self | |
self.collectionView.dragDelegate = self | |
self.collectionView.dragInteractionEnabled = true | |
} | |
extension ViewController: UICollectionViewDragDelegate { | |
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] { | |
let attributedString = String(indexPath.item) | |
let dragItem = UIDragItem(itemProvider: NSItemProvider(object: attributedString as NSItemProviderWriting)) | |
dragItem.localObject = attributedString | |
return [dragItem] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment