Latest 1.0
Homepage https://github.com/EngrAhsanAli/AADraggableView
License MIT
Platforms ios 8.0
Authors

Table of Contents

Swift 3.0 Carthage compatible CocoaPods License MIT Build Status
License MIT [CocoaPods]()

Description

AADraggableView is a light-weight and easy-to-use draggable views in screen bounds with options designed to drag any UIView. It allows to drag the UIView in any view controller.

Demonstration

You can define repositioning after dragging by following values:

sticky

View will stick with the edges with padding.

AADraggableView

free

View will free to move in whole screen

AADraggableView

edgesOnly

View will stick with nearby edges only

AADraggableView

topOnly

View will stick with top edge

AADraggableView

bottomOnly

View will stick with bottom edge

AADraggableView

leftOnly

View will stick with left edge

AADraggableView

rightOnly

View will stick with right edge

AADraggableView

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

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3+

Installation

AADraggableView can be installed using CocoaPods, Carthage, or manually.

CocoaPods

AADraggableView is available through CocoaPods. To install CocoaPods, run:

$ gem install cocoapods

Then create a Podfile with the following contents:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
pod 'AADraggableView'
end

Finally, run the following command to install it:

$ pod install

Carthage

To install Carthage, run (using Homebrew):

$ brew update
$ brew install carthage

Then add the following line to your Cartfile:

github "EngrAhsanAli/AADraggableView" "master"

Then import the library in all files where you use it:

import AADraggableView

Manual Installation

If you prefer not to use either of the above mentioned dependency managers, you can integrate AADraggableView into your project manually by adding the files contained in the Classes folder to your project.

Getting Started


Create object of draggable view

Drag UIView object from the Object Library into your UIViewController in storyboard.

AADraggableView

Set view object as draggable view

Set the view’s class to AADraggableView in the Identity Inspector.
Make sure the module property is also set to AADraggableView.

AADraggableView

Set properties and usage

You can set following properties in viewDidLoad method in your view controller.

Usage:

// IBOutlet for AADraggableView
@IBOutlet weak var view: AADraggableView

// Set options
view.delegate = self // AADraggableViewDelegate
view.respectedView = // reference view
view.reposition = // Reposition option
view.repositionIfNeeded() // Auto correct reposition

// Add delegate methods and observe changes!
func draggingDidBegan(_ sender: UIView) {
// Dragging did began of sender
}

func draggingDidEnd(_ sender: UIView) {
// Dragging did end of sender
}

Properties with description

You can use following properties:

Properties Types Description
padding CGFloat Padding from edges when reposition
duration TimeInterval Animaiton duration for reposition
respectedView UIView? Respected UIView for reference view bounds
reposition Reposition Reposition enum with options
isEnabled Bool User dragging enable or disable

Contributions & License

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

Pull requests are welcome! The best contributions will consist of substitutions or configurations for classes/methods known to block the main thread during a typical app lifecycle.

I would love to know if you are using AADraggableView in your app, send an email to Engr. Ahsan Ali

Latest podspec

{
    "name": "AADraggableView",
    "version": "1.0",
    "summary": "AADraggableView is easy-to-use draggable views with options, written in Swift.",
    "description": "AADraggableView is a light-weight and easy-to-use draggable views in screen bounds with options designed to drag any UIView. It allows to drag the UIView in any view controller.",
    "homepage": "https://github.com/EngrAhsanAli/AADraggableView",
    "screenshots": "https://raw.githubusercontent.com/EngrAhsanAli/AADraggableView/master/Screenshots/AADraggableView.png",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "engrahsanali": "[email protected]"
    },
    "source": {
        "git": "https://github.com/EngrAhsanAli/AADraggableView.git",
        "tag": "1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "AADraggableView/Classes/**/*"
}

Pin It on Pinterest

Share This