简体   繁体   中英

How to use gif with UIImageView in Xamarin.iOS without using third party library?

I want to load gif image in UIImageView. I've try to use it wih FLAnimatedImage but it not worked. I have taken imageview in storyboard and added gif to resources.

If you want to load gif image with UIImageView, I find one article that you can take a look:

https://montemagno.com/animated-gif-uiimageview-in-xamarinios/

If you try to create the gif using individual images, it will be easier, as you can see here. When you convert the native code from here to C#, you get this

UIImageView gifView = new UIImageView();
gifView.AnimationImages = new UIImage[] {
    UIImage.FromBundle("Image1.png"),
    UIImage.FromBundle("Image2.png"),
    UIImage.FromBundle("Image3.png"),
    UIImage.FromBundle("Image4.png")
};
gifView.AnimationRepeatCount = 0; // Repeat forever.
gifView.AnimationDuration = 1.0; // Every 1s.
gifView.StartAnimating();
gifView.View.Frame = new CoreGraphics.CGRect(0, 20, this.View.Bounds.Size.Width, 180); // size of the animation
this.View.AddSubview(gifView);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM