PadControl Save

A UIControl subclass for two-dimension directional input

Project README

PadControl

Carthage compatible

A UIControl subclass for two-dimension directional input. Supports customization of color and other cosmetic attributes. To use with Carthage, add the following to your Cartfile:

github "gabrieloc/PadControl"

If you prefer not using Carthage, simply copy PadControl.swift into your project.

Example Usage

Create an instance of PadControl by providing direction information (PadDirections). To create a unidirectional pad in your View Controller:


override func viewDidLoad() {
	super.viewDidLoad

	let pad = PadControl(directions: [.up])
	pad.addTarget(self, action: #selector(padUpdated), for: .valueChanged)
	view.addSubview(pad)
}

@objc func padUpdated(sender: PadControl) {
	let value = sender.value(forDirection: .up)
	// value is a a Double from 0 - 1
}

Passing different directions allows for a variety of uni or bidirectional inputs to be created. For example: X axis Y axis Both axis corner

To view all of these examples, refer to the app target in the main .xcodeproj entitled PadControl Example.

FYI

PadControl is used by SCARAB, a free quadcopter controller for iOS. If you are interested in building quadcopter software, SCARAB is also powered by QuadKit, a framework for communicating with generic quadcopters.

Open Source Agenda is not affiliated with "PadControl" Project. README Source: gabrieloc/PadControl
Stars
60
Open Issues
0
Last Commit
1 year ago
License
MIT
Tags

Open Source Agenda Badge

Open Source Agenda Rating