A framework for continuous animation in iOS widgets.
English · 한국어
Apple turns the hands of its Clock widget with _ClockHandRotationEffect. But it's a private WidgetKit API, so other apps don't get it.
ClockHandKit builds this effect at runtime and applies it, so widgets in your own apps can use it too.
ClockHandRotationKit used to do the same thing, but it stopped working in apps built with Xcode 26.1 or later on iOS 26.1. The
_clockHandRotationEffect()function it relied on now returns the view unchanged in third-party apps, without adding the effect. So I made a new framework that skips that function and builds the_ClockHandRotationEffectit used internally. 😆See the release notes for details.
Left: ClockHandKit
Right: the original ClockHandRotationKit on iOS 26.1 and later
.package(url: "https://github.com/giljihun/ClockHandKit.git", from: "0.1.2")import SwiftUI
import ClockHandKit
ZStack {
hourHand.clockHandRotationEffect(period: .hourHand)
minuteHand.clockHandRotationEffect(period: .minuteHand)
secondHand.clockHandRotationEffect(period: .secondHand)
}Set the time zone with in and the pivot with anchor.
secondHand.clockHandRotationEffect(period: .secondHand, in: .gmt, anchor: .bottom)The effect turns a view by the current time, without waiting for a new timeline entry. Place frames around a wheel and show one slot at a time through a fixed viewport. As the wheel turns, the frames play like an animation.
// A frame wheel built by your app with eight slots
frameWheel
.clockHandRotationEffect(period: .custom(8))period is the time for one full 360° turn, not the length of a single frame.
period = total frame slots / target FPS
For one copy of a 120-frame sequence:
| Target rate | period |
|---|---|
| 12 FPS | 10 seconds |
| 24 FPS | 5 seconds |
| 30 FPS | 4 seconds |
| 60 FPS | 2 seconds |
These are targets. WidgetKit and the device decide the actual rendering cadence.
Examples/ClockHandExample contains an app with a clock widget.
For frame animation, see KeyringWidget, a swinging keyring widget built with ClockHandKit.
Replace the import.
-import ClockHandRotationKit
+import ClockHandKitExisting calls such as .clockHandRotationEffect(period: 60) keep working.
For new code, the typed API reads better: .clockHandRotationEffect(period: .secondHand).
ClockHandKit requires iOS 16 or later. Don't import both modules into the same target, because their extension methods can conflict.
ClockHandKit started from octree/ClockHandRotationKit, which I contributed to as a collaborator. My heartfelt thanks to octree for all the inspiration. ❤️
ClockHandKit is available under the MIT License.


