How can I run my gif only once using FLAnimatedImage?
up vote
0
down vote
favorite
I'm using xcode 10.1 and swift 4.2, I have a gif which I made with Photoshop and it plays one time in browser and in android studio.
But when I import it in xcode and click on it in storyboard, it plays for ever. It also plays several time in my virtual simulator.
I'm creating an IOS webview app and I want to play this gif once in my splash screen and stop it at the last frame, until my webview loads.
I'm using FLAnimatedImage, I found a similar question to mine, but I couldn't find my solution. That's why I'm asking again.
I do not want to change the main library files, since I have another gif which I want to play it forever. So I just need to stop the first gif in the last frame.
You can see a small part of my code:
@IBOutlet var LogoView: FLAnimatedImageView!
LogoView.contentMode = UIView.ContentMode.scaleAspectFit
LogoView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
LogoView!.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let imageData = try! Data(contentsOf: Bundle.main.url(forResource: "logo_gif", withExtension: "gif")!)
LogoView.animatedImage = FLAnimatedImage(animatedGIFData: imageData)
Thanks in advance :)
ios swift gif
add a comment |
up vote
0
down vote
favorite
I'm using xcode 10.1 and swift 4.2, I have a gif which I made with Photoshop and it plays one time in browser and in android studio.
But when I import it in xcode and click on it in storyboard, it plays for ever. It also plays several time in my virtual simulator.
I'm creating an IOS webview app and I want to play this gif once in my splash screen and stop it at the last frame, until my webview loads.
I'm using FLAnimatedImage, I found a similar question to mine, but I couldn't find my solution. That's why I'm asking again.
I do not want to change the main library files, since I have another gif which I want to play it forever. So I just need to stop the first gif in the last frame.
You can see a small part of my code:
@IBOutlet var LogoView: FLAnimatedImageView!
LogoView.contentMode = UIView.ContentMode.scaleAspectFit
LogoView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
LogoView!.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let imageData = try! Data(contentsOf: Bundle.main.url(forResource: "logo_gif", withExtension: "gif")!)
LogoView.animatedImage = FLAnimatedImage(animatedGIFData: imageData)
Thanks in advance :)
ios swift gif
you can play with properties:loopLeft
andloopCountdown
: dndgit.com/marek/FLAnimatedImage/commit/…
– Vlad
14 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using xcode 10.1 and swift 4.2, I have a gif which I made with Photoshop and it plays one time in browser and in android studio.
But when I import it in xcode and click on it in storyboard, it plays for ever. It also plays several time in my virtual simulator.
I'm creating an IOS webview app and I want to play this gif once in my splash screen and stop it at the last frame, until my webview loads.
I'm using FLAnimatedImage, I found a similar question to mine, but I couldn't find my solution. That's why I'm asking again.
I do not want to change the main library files, since I have another gif which I want to play it forever. So I just need to stop the first gif in the last frame.
You can see a small part of my code:
@IBOutlet var LogoView: FLAnimatedImageView!
LogoView.contentMode = UIView.ContentMode.scaleAspectFit
LogoView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
LogoView!.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let imageData = try! Data(contentsOf: Bundle.main.url(forResource: "logo_gif", withExtension: "gif")!)
LogoView.animatedImage = FLAnimatedImage(animatedGIFData: imageData)
Thanks in advance :)
ios swift gif
I'm using xcode 10.1 and swift 4.2, I have a gif which I made with Photoshop and it plays one time in browser and in android studio.
But when I import it in xcode and click on it in storyboard, it plays for ever. It also plays several time in my virtual simulator.
I'm creating an IOS webview app and I want to play this gif once in my splash screen and stop it at the last frame, until my webview loads.
I'm using FLAnimatedImage, I found a similar question to mine, but I couldn't find my solution. That's why I'm asking again.
I do not want to change the main library files, since I have another gif which I want to play it forever. So I just need to stop the first gif in the last frame.
You can see a small part of my code:
@IBOutlet var LogoView: FLAnimatedImageView!
LogoView.contentMode = UIView.ContentMode.scaleAspectFit
LogoView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
LogoView!.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let imageData = try! Data(contentsOf: Bundle.main.url(forResource: "logo_gif", withExtension: "gif")!)
LogoView.animatedImage = FLAnimatedImage(animatedGIFData: imageData)
Thanks in advance :)
ios swift gif
ios swift gif
edited 12 hours ago
Dávid Pásztor
19.2k72547
19.2k72547
asked 14 hours ago
z_rou
73
73
you can play with properties:loopLeft
andloopCountdown
: dndgit.com/marek/FLAnimatedImage/commit/…
– Vlad
14 hours ago
add a comment |
you can play with properties:loopLeft
andloopCountdown
: dndgit.com/marek/FLAnimatedImage/commit/…
– Vlad
14 hours ago
you can play with properties:
loopLeft
and loopCountdown
: dndgit.com/marek/FLAnimatedImage/commit/…– Vlad
14 hours ago
you can play with properties:
loopLeft
and loopCountdown
: dndgit.com/marek/FLAnimatedImage/commit/…– Vlad
14 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You can give a loopCompletionBlock to your imageView
self.imageView.loopCompletionBlock = {_ in
self.imageView.stopAnimating()
}
Thanks, for your response. Should I write it in my ViewController.swift file?
– z_rou
10 hours ago
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
9 hours ago
Thanks a lot, It works.
– z_rou
5 hours ago
add a comment |
up vote
0
down vote
You may use following library.
https://github.com/wangjwchn/AImage
let image = AImage(url: Bundle.main.url(forResource: "test", withExtension: "gif")!)
/* Create AImageView */
let imageview = AImageView(frame:CGRect(x: 0.0, y: 50.0, width: 380.0, height: 212.0))
/* Add AImage to AImageView */
imageview.add(image: image!)
/* Start displaying animated image */
imageview.play = true
...
...
/* Stop displaying animated image */
imageview.play = false
pass true to play property when you want it to start and and pass false when you want to stop.
You can also use this AImageView class from storyboard too, change UIImageView to AImageView from class inspector.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can give a loopCompletionBlock to your imageView
self.imageView.loopCompletionBlock = {_ in
self.imageView.stopAnimating()
}
Thanks, for your response. Should I write it in my ViewController.swift file?
– z_rou
10 hours ago
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
9 hours ago
Thanks a lot, It works.
– z_rou
5 hours ago
add a comment |
up vote
1
down vote
accepted
You can give a loopCompletionBlock to your imageView
self.imageView.loopCompletionBlock = {_ in
self.imageView.stopAnimating()
}
Thanks, for your response. Should I write it in my ViewController.swift file?
– z_rou
10 hours ago
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
9 hours ago
Thanks a lot, It works.
– z_rou
5 hours ago
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can give a loopCompletionBlock to your imageView
self.imageView.loopCompletionBlock = {_ in
self.imageView.stopAnimating()
}
You can give a loopCompletionBlock to your imageView
self.imageView.loopCompletionBlock = {_ in
self.imageView.stopAnimating()
}
answered 14 hours ago
Akos Komuves
265
265
Thanks, for your response. Should I write it in my ViewController.swift file?
– z_rou
10 hours ago
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
9 hours ago
Thanks a lot, It works.
– z_rou
5 hours ago
add a comment |
Thanks, for your response. Should I write it in my ViewController.swift file?
– z_rou
10 hours ago
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
9 hours ago
Thanks a lot, It works.
– z_rou
5 hours ago
Thanks, for your response. Should I write it in my ViewController.swift file?
– z_rou
10 hours ago
Thanks, for your response. Should I write it in my ViewController.swift file?
– z_rou
10 hours ago
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
9 hours ago
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
9 hours ago
Thanks a lot, It works.
– z_rou
5 hours ago
Thanks a lot, It works.
– z_rou
5 hours ago
add a comment |
up vote
0
down vote
You may use following library.
https://github.com/wangjwchn/AImage
let image = AImage(url: Bundle.main.url(forResource: "test", withExtension: "gif")!)
/* Create AImageView */
let imageview = AImageView(frame:CGRect(x: 0.0, y: 50.0, width: 380.0, height: 212.0))
/* Add AImage to AImageView */
imageview.add(image: image!)
/* Start displaying animated image */
imageview.play = true
...
...
/* Stop displaying animated image */
imageview.play = false
pass true to play property when you want it to start and and pass false when you want to stop.
You can also use this AImageView class from storyboard too, change UIImageView to AImageView from class inspector.
add a comment |
up vote
0
down vote
You may use following library.
https://github.com/wangjwchn/AImage
let image = AImage(url: Bundle.main.url(forResource: "test", withExtension: "gif")!)
/* Create AImageView */
let imageview = AImageView(frame:CGRect(x: 0.0, y: 50.0, width: 380.0, height: 212.0))
/* Add AImage to AImageView */
imageview.add(image: image!)
/* Start displaying animated image */
imageview.play = true
...
...
/* Stop displaying animated image */
imageview.play = false
pass true to play property when you want it to start and and pass false when you want to stop.
You can also use this AImageView class from storyboard too, change UIImageView to AImageView from class inspector.
add a comment |
up vote
0
down vote
up vote
0
down vote
You may use following library.
https://github.com/wangjwchn/AImage
let image = AImage(url: Bundle.main.url(forResource: "test", withExtension: "gif")!)
/* Create AImageView */
let imageview = AImageView(frame:CGRect(x: 0.0, y: 50.0, width: 380.0, height: 212.0))
/* Add AImage to AImageView */
imageview.add(image: image!)
/* Start displaying animated image */
imageview.play = true
...
...
/* Stop displaying animated image */
imageview.play = false
pass true to play property when you want it to start and and pass false when you want to stop.
You can also use this AImageView class from storyboard too, change UIImageView to AImageView from class inspector.
You may use following library.
https://github.com/wangjwchn/AImage
let image = AImage(url: Bundle.main.url(forResource: "test", withExtension: "gif")!)
/* Create AImageView */
let imageview = AImageView(frame:CGRect(x: 0.0, y: 50.0, width: 380.0, height: 212.0))
/* Add AImage to AImageView */
imageview.add(image: image!)
/* Start displaying animated image */
imageview.play = true
...
...
/* Stop displaying animated image */
imageview.play = false
pass true to play property when you want it to start and and pass false when you want to stop.
You can also use this AImageView class from storyboard too, change UIImageView to AImageView from class inspector.
edited 14 hours ago
answered 14 hours ago
Abu Ul Hassan
233218
233218
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371912%2fhow-can-i-run-my-gif-only-once-using-flanimatedimage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you can play with properties:
loopLeft
andloopCountdown
: dndgit.com/marek/FLAnimatedImage/commit/…– Vlad
14 hours ago