Перетаскивая между UICollectionView и другим UIView, я получаю NSAttributedString, но без атрибута .font.
Функция удаления:
func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) {
session.loadObjects(ofClass: NSAttributedString.self, completion: { providers in
let dropPoint = session.location(in: self)
for attributedString in providers as? [NSAttributedString] ?? [] {
\\ gets here
for attr in attributedString.attributes(at: 0, effectiveRange: nil) {
print(attr.key, attr.value) // no attributes to print
}
}
})
}
И функция перетаскивания:
func dragItemFor(indexPath: IndexPath) -> [UIDragItem]{
if let cell = eiCollectionView.cellForItem(at: indexPath) as? EiCollactionViewCell {
if let attributedString = cell.label.attributedText {
for attr in attributedString.attributes(at: 0, effectiveRange: nil) {
print("pre drag vc: ",attr.key, attr.value)// prints the font
}
let dragItem = UIDragItem(itemProvider: NSItemProvider(object: attributedString))
dragItem.localObject = attributedString
return [dragItem]
}
}
return []
}