对UICollectionView 进行一组动画 如果想连贯性的实现 使用collectionView.performBatchUpdates(<#T##updates: (() -> Void)?##(() -> Void)?##() -> Void#>, completion: <#T##((Bool) -> Void)?##((Bool) -> Void)?##(Bool) -> Void#>)方法 (先操作数据 再更新视图)
collectionView.allowsMultipleSelection = true
是否允许多选
menu
override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool {
return true
}
override func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool {
//只显示复制 黏贴
if action == #selector(copy(_:)) || action == #selector(paste(_:)) {
return true
}
return false
}
override func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) {
switch action {
case #selector(copy(_:)):
print("复制")
case #selector(paste(_:)):
print("黏贴")
default:
break
}
}
UICollectionViewDataSourcePrefetching 预加载
网友评论