WidgetExamples icon indicating copy to clipboard operation
WidgetExamples copied to clipboard

大佬,知道怎么支持播放GIF吗?在小组件中怎么实现啊

Open Jdb156158 opened this issue 3 years ago • 3 comments

Jdb156158 avatar Jan 03 '23 08:01 Jdb156158

同问,已经有app实现了动画播放,像top widget ,dtd playlist

chdo002 avatar Jul 18 '23 01:07 chdo002

@Jdb156158 @chdo002

Generally widgets aren't designed to have animations (at least for now). If it changes, the relevant API will be added (like in the case of interactive widgets).

I'm aware of two ways of animating widgets:

  1. Private API

An example can be _clockHandRotationEffect as described in this issue.

You may have to build a library with Xcode 13, so it's available in later versions.

(There might be more hidden methods - feel free to look for yourself.)

  1. Custom fonts

You can create a timer that will change every second.

Text(.now, style: .timer)

In theory providing a custom font as described in this thread should allow implementing gif-style animations.

pawello2222 avatar Jul 21 '23 10:07 pawello2222

同问,已经有app实现了动画播放,像top widget ,dtd playlist

@chdo002 ,加我微 JDB118158168可以一起讨论

Jdb156158 avatar Jul 21 '23 14:07 Jdb156158

Added AnalogClockWidget in version 1.1.0. This widget uses an example private xcframework that may not necessarily pass Apple Review.

The tutorial how to create an xcframework with ClockHandRotationEffect can be found here.

pawello2222 avatar Apr 21 '24 19:04 pawello2222