How can I make a text field (or something that looks similar) with a number in it, which you can increase or decrease by touching it and swiping your finger up (increase) or down (decrease).
How it would work: There is a texfield with 0.0 on it. You touch it, and move your finger down. Then you see the value decrease as you move your finger further. When you stop moving your finger, the value doesn’t change.
How could this be done in Objective-C?
This answer is quite big, so I decided to put some sample code on github.
To cater for multiple labels, we’re first going to subclass
UILabel, to add a property calleddragging. We’re gong to call the classDragLabel.DragLabel.h
DragLabel.m
Interface Builder
Now you need to drag three labels into the view in IB, and change all their classes to
DragLabel. Make sure you do this before creating the outlets.After doing this, hook all the outlets up to your .m and .h. In my instance, I gave them names of label1, label2 and label3.
Now we have our label class and interface set up, its time to write the code for the view controller.
Your Controller.h should look like this. I called it DragViewController.h
Your Controller.m should look like this. I called it DragViewController.m
One last thing
To adjust the scale so it ranges from 0 to 1, only when the user drags above the label, re-implement
movedLabellike this: