Hello everyone, I've read iOS 14 widgets must be built using SwiftUI. But is it possible to show a UIKit view in the widget by wrapping it into UIViewRepresentable?
Recommended
UIKit views wrapped in UIViewRepresentable will not work in WidgetKit. When the views are encoded from your extension to be displayed they will appear blank.
That’s unfortunate, but comprehensible. Thanks a lot for the quick reply!
I had try it, but fail, we can't use UIKit,
But Apple's Map App can.......
But Apple's Map App can.......
One thing you can do is to create a screenshot from your UIView and then put this image in your SwiftUI view.
@i_Smalltalk: They are likely using MKMapSnapshotter in MapKit to capture the map into an image and displaying that in the widget. That should work for you as well.
what about an UIView contains repeatable animation? Snapshots won't work well.
I noticed the Apple engineer response said that "When the views are encoded from your extension to be displayed they will appear blank" but does he actually mean it will appear yellow with a big red crossed out circle instead of blank?