A quick and easy XY-Pad control for iOS, suitable for controlling two values on a 2D-grid such as music applications.
Add the repo url to your swift package manager.
https://github.com/cemolcay/XYPad.git
- Create an instance of
XYPad
- Listen its
valueChanged
event
var xyPad = XYPad()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(xyPad)
xyPad.addTarget(self, action: #selector(xyPadValueChanged(sender:)), for: .valueChanged)
}
@IBAction func xyPadValueChanged(sender: XYPad) {
print(sender.xValue, sender.yValue)
}
-
You can adjust the
indicatorSize
,indicatorView
,xLabel
,yLabel
,xLine
andyLine
values after the initialization. -
You can set
minXValue
andmaxXValue
-
You can set
minYValue
andmaxYValue
-
for the x-y value ranges.
-
Set
resetsToCenter
property to true if you want to the xy-pad resets its value to the center after the user lifts off their finger.