Swift CollectionViewCell重排
发布时间:2020-12-14 06:21:44 所属栏目:百科 来源:网络整理
导读:看了网易音乐里的首页可以调整栏目顺序,觉得很好,直觉告诉我,虽然它像个TableView,可它既然能随心所欲的拖动,就一定是个CollectionView吧,还真是的 iOS 9以上才能用的API 他们分别是开始拖动item,刷新item的位置(拖动中),还有结束以及取消。 // Sup
看了网易音乐里的首页可以调整栏目顺序,觉得很好,直觉告诉我,虽然它像个TableView,可它既然能随心所欲的拖动,就一定是个CollectionView吧,还真是的 // Support for reordering
@available(iOS 9.0,*)
open func beginInteractiveMovementForItem(at indexPath: IndexPath) -> Bool // returns NO if reordering was prevented from beginning - otherwise YES
@available(iOS 9.0,*)
open func updateInteractiveMovementTargetPosition(_ targetPosition: CGPoint)
@available(iOS 9.0,*)
open func endInteractiveMovement()
@available(iOS 9.0,*)
open func cancelInteractiveMovement()
前两个方法,会传入一个坐标,跟着这个坐标我们的item就会跟着移动了。然后手指离开界面需要触发 func collectionView(_ collectionView: UICollectionView,moveItemAt sourceIndexPath: IndexPath,to destinationIndexPath: IndexPath) {
}
然后我们来重新排序 链接在这CollectionView重排 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |