Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kingslay/ksrearrangeablecollectionview
https://github.com/kingslay/ksrearrangeablecollectionview
Last synced: 12 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kingslay/ksrearrangeablecollectionview
- Owner: kingslay
- License: mit
- Created: 2015-10-29T08:46:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-13T06:48:40.000Z (almost 9 years ago)
- Last Synced: 2024-10-10T16:52:55.547Z (2 months ago)
- Language: Swift
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## KDRearrangeableCollectionViewFlowLayout ##
This is a simple implementation of a drag and rearrange collection view through its layout
### Installation ###
At a minimum, just set the layout of your collection view to be a KDRearrangeableCollectionViewFlowLayout. Do this on a storyboard by selecting the layout component and changing the class name, not by changing the layout to custom by selecting the collection view. In this way you will maintain the ability to edit the size values on the storyboard.
### Data Driven ###
To fully implement the class you need to make your delegate a KDRearrangeableCollectionViewDelegate and implement its method like so:
```Swift
func moveDataItem(fromIndexPath : NSIndexPath, toIndexPath: NSIndexPath) -> Void {
let customObject = collectionViewDataArray[fromIndexPath.item]
collectionViewDataArray[fromIndexPath.item] = collectionViewDataArray[toIndexPath.item]
collectionViewDataArray[toIndexPath.item] = customObject
}
```This method will be called before the visual swap happens.
### Full Tutorial ###
Please have a look at the [article](http://karmadust.com/?p=5) for a full explanation.