DroidTimeSelection
Coming Soon:
- Full Storyboard support.
- Add Swift Package manager support.
- Add Carthage support.
- Add smoother animations for mode transitions.
- Add the color-invert effect similar to the original android selector.
Overview
As someone who used Android for a long time, I found I really miss selecting time using the Android method. So, I brought it to iOS.
DroidTimeSelection is, well, the Android-way of selecting time.
It allows using the Clock selector way of picking time:
Or the picker (iOS-way) of picking time:Installation
DroidTimeSelection is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'DroidTimeSelection'Usage
Programmatic
First of all, make sure to import "DroidTimeSelection" in all places you intend to use this.
Menu with both (both methods)
Create an instance of the menu:
let menuMethod = DroidTimeSelection()You can also modify the configuration for the menu
menuMethod.config.timeFormat = .twelve
menuMethod.config.okButtonColor = .blue
//etcYou can set an already existing time (either Time format or hours, minutes, am/pm):
menuMethod.set(time: existingTime)
//or
menuMethod.set(hour: 0, minutes: 0, am: false)To listen for menu events, access the following closures:
menuMethod.onOkTapped = { [weak self] in
let value = menuMethod.value //the time selected
//Your code here.
}
menuMethod.onCancelTapped = { [weak self] in
//Your code here.
}
menuMethod.onSelectionChanged = { [weak self] value in
//Your code here
}Clock Selection
Create an instance of the menu:
let clockMethod = DroidClockSelector(frame: .zero)Add it somewhere via absolute position or auto layout.
You can also modify the configuration for the menu
clockMethod.config.timeFormat = .twelve
clockMethod.config.timeColor = .blue
//etcYou can set an already existing time (either Time format or hours, minutes, am/pm):
clockMethod.set(time: existingTime)
//or
clockMethod.set(hour: 0, minutes: 0, am: false)To listen for menu events, access the following closures:
clockMethod.onSelectionChanged = { [weak self] value in
//Your code here
}Picker Selection
Create an instance of the menu:
let pickerMethod = DroidPickerSelector(frame: .zero)Add it somewhere via absolute position or auto layout.
You can also modify the configuration for the menu
pickerMethod.config.timeFormat = .twelve
pickerMethod.config.timeColor = .blue
//etcYou can set an already existing time (either Time format or hours, minutes, am/pm):
pickerMethod.set(time: existingTime)
//or
pickerMethod.set(hour: 0, minutes: 0, am: false)To listen for menu events, access the following closures:
pickerMethod.onSelectionChanged = { [weak self] value in
//Your code here
}Storyboard
Coming Soon.
Customization
You can customize the following aspects:
Clock Selector Configuration
largeSelectionFont: UIFont (default: .systemFont(ofSize: 18))
smallSelectionFont: UIFont (default: .systemFont(ofSize: 14))
largeSelectionColor: UIColor (default: .white)
smallSelectionColor: UIColor (default: .gray)
timeFont: UIFont (default: .systemFont(ofSize: 60))
amPmFont: UIFont (default: .systemFont(ofSize: 30))
timeColor: UIColor (default: .gray)
highlightedTimeColor: UIColor (default: .white)
selectionIndicatorColor: UIColor (default: .systemTeal)
selectionBackgroundColor: UIColor (default: .clear)
timeFormat: DroidTimeFormat (default: .twentyFour. Either .twentyFour or .twelve)Picker Selector Configuration
cancelButtonColor: UIColor (default: .white)
okButtonColor: UIColor (default: .white)
modeButtonColor: UIColor (default: .white)
okButtonText: String (default: "OK")
cancelButtonText: String (default: "CANCEL")
timeFormat: DroidTimeFormat (default: .twentyFour. Either .twentyFour or .twelve)Menu Selector (both methods) Configuration
titleFont: UIFont (default: .systemFont(ofSize: 26, weight: .bold))
titleColor: UIColor (default: .white)
pickerColor: UIColor (default: .white)
titleText: String (default: "Set Time")
timeFormat: DroidTimeFormat (default: .twentyFour)Example
To run the example project, clone the repo, and run pod install from the Example directory first.
Requirements
- iOS 11 or above.
Author
DDraiman1990, [email protected] a.k.a Nexxmark Studio.
License
DroidTimeSelection is available under the MIT license. See the LICENSE file for more info.
Attributions
Library's logo
The original icon was mixed from an icon made by Those Icons and Freepik both from www.flaticon.com.


