Skip to content

heroddaji/Dkit_Dragdrop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dkit_Dragdrop

CI Status Version License Platform

Overview

a simple subclass of UIImageview, written in Swift to enable drag and drop with animation.

Usage

let's say you want to drag an apple(DKDraggableView) to cart(UIImageView), and perform some actions when you drop on cart.

you set the drop target with

apple.enableDragging = true
apple.setDropTarget(cart)

And get notified on drop by implement the method onDropedToTarget() of DKDraggableViewDelegate protocol

class DraggableViewController: UIViewController, DKDraggableViewDelegate {

@IBOutlet weak var apple:DKDraggableView!
@IBOutlet weak var cart: UIImageView!

override func viewDidLoad() {
    super.viewDidLoad()

    apple.delegate = self
    apple.enableDragging = true
    apple.setDropTarget(cart)
}

func onDropedToTarget(sender: DKDraggableView, target:UIView) {
        NSLog("Drop to target \(target.tag)")
    }
}

Example Project

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

iOS 8.0

Installation

Dkit_Dragdrop is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Dkit_Dragdrop"

Author

daitran, [email protected]

License

Dkit_Dragdrop is available under the MIT license. See the LICENSE file for more info.