Last active
June 18, 2020 22:23
-
-
Save hamada147/855b4d995e2e1fe8246c5f914ffe31c5 to your computer and use it in GitHub Desktop.
How to check in UISlider function which Button is selected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* be sure that the slider's continuous property is also set. | |
* On the other hand, if you don't want the event to fire as the user is sliding and only when they finish sliding, | |
* set continuous to NO (or uncheck in IB) | |
*/ | |
class ViewController: UIViewController { | |
@IBOutlet weak var slider: UISlider! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
/// add on value change listner | |
self.slider.addTarget(self, action: #selector(sliderDidChange(_:)), for: .valueChanged) | |
} | |
/// on value change function | |
@objc | |
func sliderDidChange(_ sender: UISlider) { | |
// check button value here then update the wanted UILabel | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment