Comments (3)
@liudhzhyym @mromanuk Thanks for the question.
According to Apple it can't be done.
Here you can find a comment made by a Systems Engineer from Apple:
[...] However, you cannot update views to the time other than the relative date text label. So you cannot replicate the Clock widget for example and have second hands on a clock tick by while the widget is visible. Sorry.
Also, from the Human Interface Guidelines for Widgets:
Keep your widget up-to-date. To remain relevant and useful, widgets should periodically refresh their information. Widgets don’t support continuous, real-time updates, and the system may adjust the limits for updates depending on various factors.
My understanding is that the only way for third-party apps to provide such animations is to use private API. The system Clock Widget does this after all, so it might actually be possible to replicate this behaviour using some private methods that I'm not aware of.
I didn't really look into it myself yet (will probably do when I have more time) but in the meantime you can see this post for a starter:
from widgetexamples.
I want to add a homescreen widget to my app, just like the iOS system Clock app, the second hand keeps moving every second. I have been searching on Google and Github for a long time and have not found a suitable solution. I have seen that there are already third-party apps that can implement such desktop widgets.
Do you know how do they do it?
I saw the same, I'm building a Widget App and I would like to have the sub second hand on my clock. Did you find out?
from widgetexamples.
It looks like the private method you were looking for is _clockHandRotationEffect
:
extension SwiftUI.View {
@available(iOS 14.0, macOS 11, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func _clockHandRotationEffect(_ period: WidgetKit._ClockHandRotationEffect.Period, in timeZone: Foundation.TimeZone, anchor: SwiftUI.UnitPoint = .center) -> some SwiftUI.View
}
If you'd like to investigate it more, this code can be found in the WidgetKit framework module.
As I mentioned in the post above, the whole tutorial can be found here:
And here's the path to the original WidgetKit module:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/WidgetKit.framework/Modules/WidgetKit.swiftmodule
Please bear in mind that this is a private method and not approved by Apple - it may stop working any time or your app might be rejected (even after initially approved).
from widgetexamples.
Related Issues (17)
- how to set countdown time with different color from time to time HOT 1
- Manage and refresh widget without opening app HOT 2
- Compilation error: Type 'Binding<NavigationSplitViewVisibility>' has no member 'doubleColumn' HOT 1
- Custom search collection HOT 1
- Digital clock 如何每秒更新时间呢? HOT 2
- iOS17的小组件时间线刷新问题 HOT 1
- Play/Pause audio from widget HOT 1
- CoreData widget example
- How to reset intent extension configurations in WidgetKit?
- Adding onDelete on List ForEach HOT 1
- Question about coreDataStack HOT 1
- Data sharing from iOS app to Lock Screen widget and Watch widget HOT 3
- Do you need to create a separate widgets project to support ios16 or do you want to add this directly to the previous widgets HOT 3
- URLImageView Cache images HOT 1
- Countdown widget does not show as Ideal effect😭 HOT 2
- 大佬,知道怎么支持播放GIF吗?在小组件中怎么实现啊 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from widgetexamples.