代码比较简单不用解释
-(UIImageView *)singPict{ if (!_singPict) {// _singPict=[[UIImageView alloc]initWithFrame:CGRectMake(screenWidth/2-140, screenHeight/2-85,280, 80)]; _singPict.contentMode=UIViewContentModeScaleAspectFit; _singPict.backgroundColor=[UIColor clearColor]; UIImage *im1 = [UIImage imageNamed:@"singPict1.png"]; UIImage *im2 = [UIImage imageNamed:@"singPict2.png"]; UIImage *im3 = [UIImage imageNamed:@"singPict3.png"]; UIImage *im4 = [UIImage imageNamed:@"singPict4.png"]; NSArray *imArr = @[im1,im2,im3,im4]; [_singPict setAnimationImages:imArr]; //设定动画时间 [_singPict setAnimationDuration:0.5]; //设置播放次数,0表示无限播放 [_singPict setAnimationRepeatCount:0]; //开始播放 [_singPict startAnimating]; //结束播放 // [_singPict stopAnimating]; [self.view addSubview:_singPict]; } return _singPict; }