UIViewdraggable
  • September 17, 2023

UIView category that adds dragging capabilities.

Screenshot


Setup with CocoaPods


  • Add pod 'UIView+draggable' to your Podfile
  • Run pod install
  • Run open App.xcworkspace

Setup with Carthage


github “andreamazz/UIView-draggable”

Objective-C

Import UIView+draggable.h in your controller’s header file

Swift

If you are using use_frameworks! in your Podfile, use this import:

import UIView_draggable

Usage


Call enableDragging on a UIView instance

Objective-C

// Enable dragging
[self.view enableDragging];

Swift

view.enableDragging()

Options


The movement area can be restricted to a given rect:

view.cagingArea = CGRectMake(0, 0, 200, 200)

The movement can be restricted over one coordinate:

view.shouldMoveAlongX = true
view.shouldMoveAlongY = true

The area where the dragging action starts can be configured:

view.handle = CGRectMake(0, 0, 20, 20)

GitHub


View Github

YOU MIGHT ALSO LIKE...
ACarousel

A carousel view for SwiftUI

Sparklines for macOS, iOS and tvOS

A lightweight sparkline component, supporting Swift, SwiftUI, macCatalyst and Objective-C.     What is a sparkline? A sparkline is a very ...

Light Chart

LightChart is a lightweight SwiftUI package with line charts implementation. You can use it when you need only a chart that will perfectly ...

SwiftUICharts

Swift package for displaying charts effortlessly. V2 Beta is here 🎉🎉🎉 V2 focuses on providing a strong and easy to ...

SwiftUI BarChart

Lightweight and easy to use SwiftUI chart library for all Apple platforms