10Clock
  • April 25, 2024
Dark and MysteriousđŸ•¶

Usage


The control itsself is TenClock. Add that to your view hierarchy, and constrain it to be square (thats kindof important).

to set times, do:

self.tenClock.startDate = NSDate()
self.tenClock.endDate = NSDate. //sometime later

make the date today. then, to get updates for when the date changes, adopt the protocol TenClockDelegate:

import TenClock
class ViewController: UIViewController, TenClockDelegate {
//Executed for every touch.
func timesUpdated(_ clock:TenClock, startDate:Date, endDate:Date ) -> (){
//…
}

func timesChanged(clock:TenClock, startDate:NSDate, endDate:NSDate ) -> (){
print(“start at: \(startDate), end at: \(endDate)”)
self.beginTimeLabel.text = dateFormatter.stringFromDate(startDate)
self.endTimeLabel.text = dateFormatter.stringFromDate(endDate)
}
// …

Contributing


The goals of the project at this point should be testing for edgecase behavior and expanding customizability.

Please do contribute, open an issue if you have a question. Then Submit a PR! 😀

Install via CocoaPods


CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build 10Clock

To integrate 10Clock into your Xcode project using CocoaPods, specify it in your Podfile:

source ‘https://github.com/CocoaPods/Specs.git’
platform :ios, ‘10.0’
use_frameworks!

target ‘<Your Target Name>’ do
pod ’10Clock’
end

GitHub


View Github

#clock #datetime #time-picker #timer
YOU MIGHT ALSO LIKE...
How to take action when a property changes

1. Taking Action When a Property Changes: Property Observers Swift lets you observe and respond to changes in a property’s ...

How to create your own structs? How to compute property values dynamically?

1. Creating Your Own Structs In Swift, a struct is a value type that you define with the struct keyword. ...

How to use trailing closures and shorthand syntax?

1. Trailing Closure Syntax When the last parameter to a function is a closure, you can write that closure after ...

How to create and use closures?

1. What Is a Closure (and Why Swift Loves Them) A closure in Swift is a self-contained block of functionality ...

How to provide default values for parameters How to handle errors in functions

1. Providing Default Values for Function Parameters (Deep Dive) 1.1 Syntax and Ordering Declaration You assign a default right in ...