SwiftUI library to display a clock. You can move the arms to change the time, change the style of the clock and customise some configurations.
Clock UI for SwiftUI
This library has been tested
struct ContentView: View {
@State private var date = Date()
var body: some View {
ClockView().environment(\.clockDate, $date)
}
}
Swift
Simply set .environment(\.clockDate, $date)
$date
has to be a binding.
If you want something constant (just for showing the time), you could pass .constant(yourDate)
There is 4 different clock style:
STYLEPICTUREClassicArt NouveauDrawingSteampunk
To set the style: .environment(\.clockStyle, .steampunk)
for Steampunk style for instance.
struct ContentView: View {
@State private var clockStyle: ClockStyle = .classic
var body: some View {
ClockView().environment(\.clockStyle, clockStyle)
}
}
#clock #swiftui