In my app i have widget support, And now i want to add a gif on my widget. Is it possible?
If adding a gif on widget is possible, then please provide me some example or source.
In my app i have widget support, And now i want to add a gif on my widget. Is it possible?
If adding a gif on widget is possible, then please provide me some example or source.
I'm not sure if I got you right, but I'll give the solution from what I know.
Below is an example
func getTimeline(for configuration: GifCartoonIntent, in context: Context, completion: @escaping (Timeline<GifCartoonEntry>) -> ()) {
var gifModel: GIFModel!
if let selected = GlobalData.shared.gifCartoonModels.first(where: {$0.image == configuration.models?.identifier}) {
gifModel = selected
} else {
gifModel = model
}
let index = getGIFIndex(gifModel.total)
let entry = GifCartoonEntry(date: Date(), model: gifModel, index: index)
let timeline = Timeline(entries: [entry], policy: .never)
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
completion(timeline)
WidgetCenter.shared.reloadTimelines(ofKind: WidgetKindType.gifCartoonWidget.rawValue)
})
}