How do I have my UISlider
go from 1-100
in increments of 5
?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
For anyone looking for the Swift syntax...
Alternatively, just create an Action function with the Assistant Editor (what I did ultimately)...
name label as "stepperValue"
@IBAction func inc(sender: AnyObject) {
stepperValue.text = "(Int(stepper.value) * 5 )"
click the stepper and it will increment by 5
There is another way to active the stepper functionality. works in a general case
Example:
range of data is 0 - 2800 and I want the increments to be in 25 unit values. I would do the following
in the example above my slider would be set in IB to range 0 - 112. and my code would be (int)slider.value * 25.
if you then have a text field that can be modified for direct input you would just do the opposite set the slider value to the [textfield.text intValue]/ unitsteps.
In swift 3, slider with increments +/- 7:
...
...
Add a target like this:
And in the valueChanged function set the value to the closest value that is divisible by 5.
A slightly more elegant solution in Swift could be something like this
This way you get steps of 5. You can read more about the setup in my post.