A more interactive way to display and select number.
NumberPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'NumberPicker'
Call this function in action.
func openNumberPicker() {
let numberPicker = NumberPicker(delegate: self, maxNumber: 300) // set max number
numberPicker.bgGradients = [.red, .yellow]
numberPicker.tintColor = .white
numberPicker.heading = "Weight"
numberPicker.defaultSelectedNumber = 150 // set default selected number
self.present(numberPicker, animated: true, completion: nil)
}
You can change gradient color and tint color and title
numberPicker.bgGradients = [.red, .yellow]
numberPicker.tintColor = .white
numberPicker.heading = "Weight"
extension ViewController: NumberPickerDelegate {
func selectedNumber(_ number: Int) {
print(number)
}
}
Yash Thaker, yashthaker7@gmail.com
NumberPicker is available under the MIT license. See the LICENSE file for more info.