Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MarioIannotta/SplitViewDragAndDrop
Drag and drop between your apps in split view mode on iOS 9
https://github.com/MarioIannotta/SplitViewDragAndDrop
drag-and-drop ipad multitasking split-view swift
Last synced: 3 months ago
JSON representation
Drag and drop between your apps in split view mode on iOS 9
- Host: GitHub
- URL: https://github.com/MarioIannotta/SplitViewDragAndDrop
- Owner: MarioIannotta
- License: mit
- Created: 2017-06-02T14:02:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-03T08:25:30.000Z (over 7 years ago)
- Last Synced: 2024-07-23T00:52:02.758Z (3 months ago)
- Topics: drag-and-drop, ipad, multitasking, split-view, swift
- Language: Swift
- Homepage:
- Size: 1.98 MB
- Stars: 329
- Watchers: 13
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - SplitViewDragAndDrop - Easily add drag and drop to pass data between your apps in split view mode. (Gesture / Getting Started)
- awesome-ios-star - SplitViewDragAndDrop - Easily add drag and drop to pass data between your apps in split view mode. (Gesture / Getting Started)
README
# SplitViewDragAndDrop
Easily add drag and drop to pass data between your apps[![Platform](http://img.shields.io/badge/platform-ios-red.svg?style=flat
)](https://developer.apple.com/iphone/index.action)
[![Swift 3](https://img.shields.io/badge/Swift-3-orange.svg?style=flat)](https://developer.apple.com/swift/)
[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/SplitViewDragAndDrop.svg)](https://img.shields.io/cocoapods/v/SplitViewDragAndDrop.svg)# Setup
- Add ```pod 'SplitViewDragAndDrop'``` to your Podfile or copy the "SplitViewDragAndDrop" folder into your project
- Make sure to call
```SplitViewDragAndDrop.configure(groupIdentifier: )``` in ```application:didFinishLaunchingWithOptions:```. **Your apps must share that app group in order to communicate**.
- Configure the view you want to drag with ```SplitViewDragAndDrop.handleDrag(viewToDrag: , identifier: , dataToTransfer: )```
where
- **viewToDrag** is a UIView and it will be snapshotted and dragged around
- **identifier** is a string rappresenting an unique identifier.
- **dataToTransfer** is a Data, it could be an image, a pdf ecc..
- Configure the drop observer with
```
SplitViewDragAndDrop.addDropObserver(
targetView: ,
identifier: ,
draggingBegan: { frame, draggedViewSnapshotImage, dataTransfered in
// the drag is began, here you can perform some ui changes in order to tell the user where to drag the item
},
draggingValidation: { frame, draggedViewSnapshotImage, dataTransfered in
return
},
completion: { frame, draggedViewSnapshotImage, dataTransfered, isValid in
// the drag is complete and you can use dataTrasfered if you want
}
)
```
where
- **targetView** is a UIView and it will be the center of the dragged item when the user end the dragging and the validation succedded
- **identifier** is a string rappresenting an unique identifier
- **draggingBegan** is a closure that will be called when the drag is began
- **draggingValidation** is a closure that will be called when the drag is ended. You have to return a value that indicate if the drag is valid or not. If that value is true, the dragged view will be moved to the center of the **targetView**, otherwise it will be moved back to it's original position.
- **completion** is a closure that will be called after the validation.
# Demo
In this repository you can also find a demo.# Info
If you like this git you can follow me here or on twitter :) [@MarioIannotta](http://www.twitter.com/marioiannotta)Cheers from Italy!