Skip to content

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.

License

Notifications You must be signed in to change notification settings

EngrAhsanAli/AADraggableView

Repository files navigation

Table of Contents

#AADraggableView

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.

-- free

View will free to move in whole screen

-- edgesOnly

View will stick with nearby edges only

-- topOnly

View will stick with top edge

-- bottomOnly

View will stick with bottom edge

-- leftOnly

View will stick with left edge

-- rightOnly

View will stick with right edge

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.

##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.

##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

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published