use*_*868 10 animation objective-c uiimageview ios
如何为来自Web服务的图像设置动画.我得到了代码来动画来自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];
Run Code Online (Sandbox Code Playgroud)
Vin*_*odh 15
从webservice下载图像;
NSData *imageData = [NSData dataWithContentsOfURL:"*Url from web service*"];
UIImage *imageOne = [UIImage imageWithData:imageData];
Run Code Online (Sandbox Code Playgroud)
可能从Web服务下载所有图像并创建一个类似的数组
NSArray *imagesArray = [NSArray arrayWithObjects:imageOne...........,nil];
Run Code Online (Sandbox Code Playgroud)
并使用一点修改
UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = imagesArray;
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22134 次 |
| 最近记录: |