How to disable animation on Widget? Specifically, animation with Text(style: .timer)

While it's wonderful that the Widget provides animation and interaction capabilities, I've encountered a slight issue with the animation when using it to display a countdown. It tends to become bothersome.

Is there a method to disable the animation?

Replies

I have the same issue.

Text(value) Text(value).animation(nil) Text(value).animation(.none)

This does not work.

Try using .contentTransition(.identity). Does that help?

Hi reed.1325. Thanks for your answer. It works only for Text() element. For example, when updating a widget, I see a fade animation for some elements. This creates the blinking effect of the entire widget. I would like to be able to disable this animation.

  • Try setting .id() to some constant value on the group of elements you don't want to fade, along with .transition(nil). Setting the id to a constant tells the view system the view's identity hasn't changed. I'm not sure this would work with a timer but with other elements it should.

Add a Comment

deleted

Any solutions?

Find a solution:

VStack() { Text(entry.date, style: .time) Text(Calendar.current.startOfDay(for: Date()), style: .timer) .contentTransition(.identity) }

Found a solution! Check out Apple's documentation here: https://developer.apple.com/documentation/widgetkit/animating-data-updates-in-widgets-and-live-activities#Disable-animations. Using .transition(.identity) worked for me, as the documentation suggests.

Disable content animation use .contentTransition(.identity), disable view animation use .transition(.identity)