|
So I've been unable to figure out displaying a fixed set of .GIF images in my app. the Xcode Assets folder doesn't seem to like the .GIF file type. I've found a few I have a set of pre-saved .GIF images that I want to display in my app but cannot figure out where/how to place and reference them. |
|
It's for Swift 3 so you may run into issues you need to correct, but you could try this: iOSDevCenters+GIF.swift Never used it myself so I can't say too much about it, but what have you got to lose? There's also this package: Gifu |
|
@roosterboy Thank you, I've also come across this package which seems straight forward, but I'm having trouble implementing it. https://github.com/kirualex/SwiftyGif I do not understand the UIView and UIViewImage uses. Simply adding this code to a function or extension yields problems. Mainly it just says that "view" is not in scope, but I do not know why. import SwiftyGif
|
|
Are you using UIKit or SwiftUI to build your application? If you are using UIKit, can you post your If you are using SwiftUI, can you post your |
|
I plan to make this a bit more robust than it currently is, but this is the entire Struct. I just get an error that "view" is not in scope on the Does it need to be in a UIView struct and referenced for display?
|
|
Yeah, that code is meant to work with UIKit but you are trying to use it in SwiftUI. You can load a UIKit Also, you can't use a |
|
That code is designed for UIKit, but you're attempting to use it in SwiftUI. A UIKit UIImage can be loaded into a SwiftUI Image, however it seems to be a static GIF with no looping. To gain complete functionality, you might need to cover the UIImageView with a UIViewRepresentable. A do...catch block is also not allowed within a SwiftUI View. Being able to use that code in a |
|
Just to close this out. I finally managed to get this going using a different package and some old fashioned coco pod work. https://cocoapods.org/pods/SSSwiftUIGIFView Once the dependency is setup, it really is as simple as adding your .gif file to your apps folder structure, and adding this code to draw up the container
|
SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.