Gabul
Gabul

Reputation: 41

How to add GIF file in Xcode assets foler?

I'm using Xcode 12.4 and I want to use GIF image in my app.

So I put GIF Image in Assets.xcassets folder.

But UIImage can't recognize the GIF file with this error message

CoreUI: attempting to lookup a named image 'imgname' with a type that is not a data type in the AssetCatalog

enter image description here

When I open Assets.xcassets folder in xcode, the file is represented like above image.

How to solve this error? I use code to get image

UIImage.animatedImage(with: [UIImage(named: "img_name")!], duration: 15.0)

Thank you.

Upvotes: 0

Views: 633

Answers (1)

yycking
yycking

Reputation: 1311

That's because UIImage is not support file in data set.

You must use NSDataAsset to load gif data from data set

Upvotes: 0

Related Questions