#import "ViewController.h" @interface ViewController () - (IBAction)drink; @property (weak, nonatomic) IBOutlet UIImageView *tom; @end @implementation ViewController - (IBAction)drink { //1. 加载全部的动画图片 NSMutableArray *images = [NSMutableArray array]; // 定义一个 images的空数组 //下面两行怎么添加不了图片到整个UIimage View 的背景啊? UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,600,1000)]; // imageView.image = [UIImage imageNamed:@"drink_01.jpg"]; for (int i = 0; i<81; i++) { //计算文件名 NSString *filename = [NSString stringWithFormat:@"drink_%02d.jpg",i]; //加载图片 UIImage *image = [UIImage imageNamed:filename]; [images addObject:image]; } self.tom.animationImages= images; //2. 设置播放次数 self.tom.animationRepeatCount = 1; self.tom.animationDuration = images.count *0.1; [self.tom startAnimating]; } @end
//下面两行怎么添加不了图片到整个UIimage View 的背景啊?
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,600,1000)]; //
imageView.image = [UIImage imageNamed:@”drink_01.jpg”];
运行后整个 UIImage View 是空白的 咋回事啊 新手不太明白呢
解决方案
40
没有添加进subview里面,加个self.view.addSubview(imageview);