【发布时间】:2020-04-08 21:47:24
【问题描述】:
我有一个简单的enum 作为我的两个UICollectionView 的数据结构:
enum ToolBarItem {
case inking(PKInkingTool.InkType, UIColor, CGFloat)
case lasso
case eraser(PKEraserTool.EraserType)
}
UICollectionView 两种型号都只是:
private(set) var tools = [ToolBarItem]()
我希望能够在两个UICollectionView 内和之间拖放项目,因此我需要以某种方式将其变成一个 dragItem。
我读过关于将我的enum 嵌入到一个类中并实现NSItemProviderWriting、NSItemProviderReading 和Codable 以创建一个项目提供者。但这很混乱,我希望有更好的解决方案,因为它只是一个enum。
我很乐意收到任何帮助或建议。
【问题讨论】:
标签: ios swift enums uicollectionview drag-and-drop