Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/KyoheiG3/TableViewDragger
A cells of UITableView can be rearranged by drag and drop.
https://github.com/KyoheiG3/TableViewDragger
drag indexpath ios swift uitableview
Last synced: 5 days ago
JSON representation
A cells of UITableView can be rearranged by drag and drop.
- Host: GitHub
- URL: https://github.com/KyoheiG3/TableViewDragger
- Owner: KyoheiG3
- License: mit
- Created: 2015-09-24T12:21:23.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-08-27T12:53:54.000Z (over 1 year ago)
- Last Synced: 2024-04-24T18:57:46.659Z (8 months ago)
- Topics: drag, indexpath, ios, swift, uitableview
- Language: Swift
- Homepage:
- Size: 1.42 MB
- Stars: 530
- Watchers: 9
- Forks: 51
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - TableViewDragger - A cells of UITableView can be rearranged by drag and drop. (UI / Table View / Collection View)
- awesome-ios-star - TableViewDragger - A cells of UITableView can be rearranged by drag and drop. (UI / Table View / Collection View)
README
# TableViewDragger
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Version](https://img.shields.io/cocoapods/v/TableViewDragger.svg?style=flat)](http://cocoadocs.org/docsets/TableViewDragger)
[![License](https://img.shields.io/cocoapods/l/TableViewDragger.svg?style=flat)](http://cocoadocs.org/docsets/TableViewDragger)
[![Platform](https://img.shields.io/cocoapods/p/TableViewDragger.svg?style=flat)](http://cocoadocs.org/docsets/TableViewDragger)![simple](https://user-images.githubusercontent.com/5707132/33757706-a5b5cf6c-dc3e-11e7-9275-b54b7897da59.gif)![image](https://user-images.githubusercontent.com/5707132/33757803-19c44622-dc3f-11e7-913e-b39aa3f45791.gif)
This is a demo that uses a `TableViewDragger`.
#### [Appetize's Demo](https://appetize.io/app/p92e7wrmfkq32t473fuavn8bmm)
## Requirements
- Swift 5.0
- iOS 11.0 or later## How to Install TableViewDragger
#### CocoaPods
Add the following to your `Podfile`:
```Ruby
pod "TableViewDragger"
```#### Carthage
Add the following to your `Cartfile`:
```Ruby
github "KyoheiG3/TableViewDragger"
```## Usage
### TableViewDragger Variable
```swift
weak var delegate: TableViewDraggerDelegate?
```
* Delegate of `TableViewDragger`.```swift
weak var dataSource: TableViewDraggerDataSource?
```
* DataSource of `TableViewDragger`.```swift
var isHiddenOriginCell: Bool
```
* It will be `true` if want to hide the original cell.
* Default is `true`.```swift
var zoomScaleForCell: CGFloat
```
* Zoom scale of cell in drag.
* Default is `1`.```swift
var alphaForCell: CGFloat
```
* Alpha of cell in drag.
* Default is `1`.```swift
var opacityForShadowOfCell: Float
```
* Opacity of cell shadow in drag.
* Default is `0.4`.```swift
var scrollVelocity: CGFloat
```
* Velocity of auto scroll in drag.
* Default is `1`.### TableViewDragger Function
```swift
init(tableView: UITableView)
```
* `UITableView` want to drag.### TableViewDraggerDataSource Function
```swift
optional func dragger(_ dragger: TableViewDragger, cellForRowAt indexPath: IndexPath) -> UIView?
```
* Return any cell if want to change the cell in drag.```swift
optional func dragger(_ dragger: TableViewDragger, indexPathForDragAt indexPath: IndexPath) -> IndexPath
```
* Return the indexPath if want to change the indexPath to start drag.### TableViewDraggerDelegate Function
```swift
func dragger(_ dragger: TableViewDragger, moveDraggingAt indexPath: IndexPath, newIndexPath: IndexPath) -> Bool
```
* If allow movement of cell, please return `true`. require a call to `moveRowAtIndexPath:toIndexPath:` of UITableView and rearranged of data.```swift
optional func dragger(_ dragger: TableViewDragger, shouldDragAt indexPath: IndexPath) -> Bool
```
* If allow dragging of cell, prease return `true`.## Author
#### Kyohei Ito
- [GitHub](https://github.com/kyoheig3)
- [Twitter](https://twitter.com/kyoheig3)Follow me 🎉
## LICENSE
Under the MIT license. See LICENSE file for details.