How can I run my gif only once using FLAnimatedImage?
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 |
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:loopLeftandloopCountdown: dndgit.com/marek/FLAnimatedImage/commit/…
– Vlad
Nov 19 '18 at 10:14
add a comment |
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 Nov 19 '18 at 11:24
Dávid Pásztor
21.9k82749
21.9k82749
asked Nov 19 '18 at 9:44
user_5user_5
74
74
you can play with properties:loopLeftandloopCountdown: dndgit.com/marek/FLAnimatedImage/commit/…
– Vlad
Nov 19 '18 at 10:14
add a comment |
you can play with properties:loopLeftandloopCountdown: dndgit.com/marek/FLAnimatedImage/commit/…
– Vlad
Nov 19 '18 at 10:14
you can play with properties:
loopLeft and loopCountdown: dndgit.com/marek/FLAnimatedImage/commit/…– Vlad
Nov 19 '18 at 10:14
you can play with properties:
loopLeft and loopCountdown: dndgit.com/marek/FLAnimatedImage/commit/…– Vlad
Nov 19 '18 at 10:14
add a comment |
2 Answers
2
active
oldest
votes
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?
– user_5
Nov 19 '18 at 14:11
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
Nov 19 '18 at 14:34
Thanks a lot, It works.
– user_5
Nov 19 '18 at 18:24
add a comment |
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 |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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?
– user_5
Nov 19 '18 at 14:11
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
Nov 19 '18 at 14:34
Thanks a lot, It works.
– user_5
Nov 19 '18 at 18:24
add a comment |
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?
– user_5
Nov 19 '18 at 14:11
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
Nov 19 '18 at 14:34
Thanks a lot, It works.
– user_5
Nov 19 '18 at 18:24
add a comment |
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 Nov 19 '18 at 10:12
Akos KomuvesAkos Komuves
418
418
Thanks, for your response. Should I write it in my ViewController.swift file?
– user_5
Nov 19 '18 at 14:11
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
Nov 19 '18 at 14:34
Thanks a lot, It works.
– user_5
Nov 19 '18 at 18:24
add a comment |
Thanks, for your response. Should I write it in my ViewController.swift file?
– user_5
Nov 19 '18 at 14:11
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
Nov 19 '18 at 14:34
Thanks a lot, It works.
– user_5
Nov 19 '18 at 18:24
Thanks, for your response. Should I write it in my ViewController.swift file?
– user_5
Nov 19 '18 at 14:11
Thanks, for your response. Should I write it in my ViewController.swift file?
– user_5
Nov 19 '18 at 14:11
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
Nov 19 '18 at 14:34
Yes, where you configure the imageView, typically in the ViewController.
– Akos Komuves
Nov 19 '18 at 14:34
Thanks a lot, It works.
– user_5
Nov 19 '18 at 18:24
Thanks a lot, It works.
– user_5
Nov 19 '18 at 18:24
add a comment |
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 |
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 |
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 Nov 19 '18 at 10:15
answered Nov 19 '18 at 10:07
Abu Ul HassanAbu Ul Hassan
252218
252218
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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:
loopLeftandloopCountdown: dndgit.com/marek/FLAnimatedImage/commit/…– Vlad
Nov 19 '18 at 10:14