gpt4 book ai didi

ios - 在 uiimageview 中动画图像

转载 作者:技术小花猫 更新时间:2023-10-29 11:01:07 26 4
gpt4 key购买 nike

如何为来自网络服务的图像制作动画。我从 bundle 中获得了动画图像的代码。如何从 url 数组加载图像

代码附在下面

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image1.gif"],
[UIImage imageNamed:@"image2.gif"],
[UIImage imageNamed:@"image3.gif"],
[UIImage imageNamed:@"image4.gif"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];

最佳答案

从网络服务下载图片:

NSData *imageData = [NSData dataWithContentsOfURL:"*Url from web service*"];
UIImage *imageOne = [UIImage imageWithData:imageData];

可能从网络服务下载所有图像并创建一个数组,如:

NSArray *imagesArray = [NSArray arrayWithObjects:imageOne...........,nil];

并稍作修改即可使用:

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = imagesArray;
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];

关于ios - 在 uiimageview 中动画图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17274201/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com