Post

Replies

Boosts

Views

Activity

Reply to Why is my widget drawn twice?
Home screen widgets are drawn twice per timeline entry: once for light mode and once for dark mode. That allows it to switch between the modes instantly without having to rerun the widget extension. Lock screen widgets are drawn many more times that that: they render once for every combination of: dark/light mode, vibrancy, privacy, etc.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Reply to Widget Not Refreshing.
I don't know if this is the full code or reduced for display but there are a couple things I would suggest looking at: Your View is not valid. You can't put a bunch of Text() views directly in the body. Try putting a VStack around the ForEach loop. Inside of the dataTask block, make sure that the data object is not nil. You are force unwrapping the optional, but without ever making sure that it isn't nil.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’21
Reply to Why is my widget drawn twice?
Home screen widgets are drawn twice per timeline entry: once for light mode and once for dark mode. That allows it to switch between the modes instantly without having to rerun the widget extension. Lock screen widgets are drawn many more times that that: they render once for every combination of: dark/light mode, vibrancy, privacy, etc.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to How can the image of the lock screen widget keep its original color (eg: color)?
That is not possible. Lock screen widgets, at least as of iOS 16 beta 4, always use the vibrant mode. That mode renders varying opacity with a frosted glass look based on the gray scale version of colors in the view. The other render modes are primarily meant for watchOS at this time. There is no way to show color in lock screen widgets.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Widget Not Refreshing.
I don't know if this is the full code or reduced for display but there are a couple things I would suggest looking at: Your View is not valid. You can't put a bunch of Text() views directly in the body. Try putting a VStack around the ForEach loop. Inside of the dataTask block, make sure that the data object is not nil. You are force unwrapping the optional, but without ever making sure that it isn't nil.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’21