I need a slider for displaying real time in slider-label from 12-00 AM to 11-45 PM with step size 15 minutes. But I just have no idea how to do it. Сan anybody give some suggestions to me?
相关问题
- 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
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
You may use NSTimer to call a method every 15 minutes and update the slider/label with the current time.
You may want to take a look at NSDateFormatter, it may be useful to obtain proper string representation for your date.
Create a slider, and in the view controller, have the slider change the label as the value on the slider changed. To set the range of values, change the range in the Storyboard under the properties (you can set the change interval to steps of 15 there too). You may want to give it the interval in minutes or something similar and then just convert that to time :)
If you just need a time chooser with slider, use the following code in the sliderChanged: handler:
I'm adding another answer to add code. Yes, you can get the value from the slider and then set the text of the label after converting the value to a time. Like so: