你的位置:首页 > 操作系统

[操作系统]【代码笔记】利用图片序列创建动态图片效果


一,效果图。

二,代码。

RootViewController.m

复制代码
- (void)viewDidLoad{  [super viewDidLoad];  // Do any additional setup after loading the view.      //显示图片的UIImageView  UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];  imageview.backgroundColor=[UIColor redColor];  [self.view addSubview:imageview];    //动画的实现  NSMutableArray * images = [NSMutableArray arrayWithCapacity:6];  for (int i = 1; i <= 6; i++)  {    NSString * imageName = [NSString stringWithFormat:@"%d.jpg",i];    UIImage * image = [UIImage imageNamed:imageName];        [images addObject:image];  }  imageview.animationImages = images;  imageview.animationDuration = 0.3;  [imageview startAnimating];}
复制代码