File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ MagicTimer is a UIView based timer that displays a countdown or count-up timer.<
2222## Features
2323- [x] Fully customizable design
2424- [x] Support stop watch / count down mode
25+ - [x] Support custom time formatter
2526- [x] Suppport in background time calculation
2627- [x] Modifable time interval / step
2728- [x] Fully Managable: start, pause, reset
@@ -135,7 +136,28 @@ A callback that notifies when timer state did change.
135136``` swift
136137public var didStateChange: ((MGStateManager.TimerState) -> Void )?
137138```
139+ # Formatter
140+ MagicTimerView can accept custom time formatter. Any time formatter should confrom ` MGTimeFormatter ` .
141+ ### ` MGTimeFormatter `
142+ ``` swift
143+ public protocol MGTimeFormatter
144+ ```
145+ Sample custom time formatter
146+ ```swift
138147
148+ class CustomTimeFormatter: MGTimeFormatter {
149+ let dateComponent = DateComponentsFormatter ()
150+
151+ init () {
152+ dateComponent.unitsStyle = .positional
153+ dateComponent.allowedUnits = [.second ]
154+ }
155+ func converToValidFormat (ti : TimeInterval) -> String ? {
156+ dateComponent.string (from : ti)
157+ }
158+ }
159+
160+ ```
139161# Observe
140162You can observe elapsed time in two ways. <br />
141163** First** : using ` elapsedTime ` property.
You can’t perform that action at this time.
0 commit comments