PadCodedocs

Clock Hand

Turns it like a clock's hand, from 12 o'clock: round once a minute for a second hand, once an hour for a minute hand, twice a day for an hour hand. On the Home Screen it keeps moving between the widget's updates.

Group: Graphics and rendering · Works on: Every view

#When to use it

For an analog clock's hands, on a widget or in an app. Draw each hand pointing straight up, at 12, in a view that fills the clock, and give it a Clock Hand: second, minute or hour. It turns the hand to the time, and keeps it turning.

#Example

A widget's clock: a Circle for the face, and three hands, each a Column that fills the clock with a Capsule in its top half and a clear Color below it. Their Clock Hands are hour, minute and second. The AI Agent builds one when you ask for "an analog clock".

#Good to know

  • On the Home Screen, a widget is drawn once a minute, so a formula like second(now()) * 6 only moves once a minute. A Clock Hand uses the same effect as Apple's Clock widget, which iPadOS keeps moving between those times.
  • That effect isn't in Apple's public SDK: PadCode finds it inside WidgetKit. If a future iPadOS takes it away, the hands still show the right time, moving once a minute.
  • In the Builder and in Preview, the hands move every second.

#Add it

Select the view, open the Inspector's Style tab, open All modifiers at the bottom and tap Add modifier. Search for “Clock Hand” and tap it. Its row opens under All modifiers, with its settings.

#Settings

SettingWhat it does
Handsecond, minute or hour: how long one turn takes. Draw the hand pointing up, at 12.
AnchorThe point it turns around: the clock's center.

#Change, move or remove it

Tap the modifier's row under All modifiers to open or close its settings. Its ⋯ menu has Move Up, Move Down and Remove.

Order matters: modifiers apply top to bottom, so padding before a background makes the background bigger.

#See also