DarkMode in TimelineProvider

How to find current traitCollection inside

Code Block
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> Void)


I need it for MKMapSnapshotter.Options().traitCollection when get snapshot from MKMapSnapshotter

You can't, and you shouldn't - because the user could change their appearance from light to dark in the middle of a timeline event and your widget wouldn't update then.

I think the best solution here would be to snapshot both cases, one for light and one for dark, and the select and display the correct one in your SwiftUI view depending on the state then. You can get that by adding:

Code Block swift
@Environment(\.colorScheme) private var colorScheme: ColorScheme


In your SwiftUI file and switching on the colorScheme value.
DarkMode in TimelineProvider
 
 
Q