Coder Social home page Coder Social logo

adragdropview's Introduction

ADragDropView

Build Status

Add a Drag and drop view (swift) for your macOS app easily

I used this in my mac apps, Pushever, test APNS push notification easily and PDF Page Numberer.

Demo

Requirements

  • macOS 10.12+
  • Xcode 9.4.1+
  • Swift 4.1+

Install

Manual

Copy the ADragDropView.swift and NSDraggingInfo+FilePathURL.swift inside the ADragDropView folder to your project.

CocoaPods

pod 'ADragDropView'

On the top of view controller, add

import ADragDropView

Usage

Run the ADragDropViewExample target in Xcode to try the demo.

Drag and drop a Custom View to your view controller in Interface Builder, set its class to ADragDropView and create an IBOutlet for it.

custom view

custom class

Set delegate (usually to the view controller), dragDropView.delegate = self .

Set the allowed file extensions: dragDropView.acceptedFileExtensions = ["png", "jpg", "jpeg", "gif"] .

Implement the two delegate methods to handle dropped file(s) :

extension ViewController: ADragDropViewDelegate {
    // when one file is dropped
    func dragDropView(_ dragDropView: ADragDropView, droppedFileWithURL URL: URL) {
        
        // action to do when the file is dropped
    }
    
    // when multiple files are dropped
    func dragDropView(_ dragDropView: ADragDropView, droppedFilesWithURLs URLs: [URL]) {
        
       // action to do when the files are dropped
    }
}

adragdropview's People

Contributors

cupnoodle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.