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)
}
}
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:
Style | Picture |
---|---|
Classic | ![]() |
Art Nouveau | ![]() |
Drawing | ![]() |
Steampunk | ![]() |
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)
}
}
\.clockStyle
is typed as enum ClockStyle
which is Identifiable
, CaseIterable
, and has a convenient method to get the description (in English): public var description: String
It's very useful when you want to iterate over this enum
to let the user choose the clock style, for instance you can easily do something like this:
struct StylePicker: View {
@Binding var clockStyle: ClockStyle
var body: some View {
Picker("Style", selection: clockStyle) {
ForEach(ClockStyle.allCases) { style in
Text(style.description).tag(style)
}
}
.pickerStyle(SegmentedPickerStyle())
}
}
You can also change the color of Clock elements. Again with changing some .environment
keys.
ClockView()
.environment(\.clockArmColors, ClockArmColors(
minute: .red,
hour: .blue
))
.environment(\.clockBorderColor, .orange)
.environment(\.clockIndicatorsColor, .green)
In light mode, you could expect a result like this:
.hover
and .hoverEffect
from Swift 5.2 and Xcode 11.4Author: renaudjenny
Source Code: https://github.com/renaudjenny/SwiftClockUI
AppClues Infotech is a top Mobile App Development Company in USA building high-quality Android, iOS, and Native apps for Startups, SMBs, & Enterprises. Contact us now!
This article covers everything about mobile app wireframe design: what to do and what not, tools used in designing a mobile or web app wireframe, and more.
This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.
iPrism Tech is a one of the best and offshore mobile app development company in India, Saudi Arabia and USA. We are a major providers of android, iphone and ipad mobile app development services at economical prices.
Apple Swift App Development India: Mobile App Development India is an expert iOS Swift App Development company in India. We develop secure and robust mobile app solutions based on new Apple Swift language.