IOS基礎-UIImageView
UIImage是定義一張圖片,而UIImageVIew是定義一個視圖,然後把圖片放進去
- (void)viewDidLoad{ [super viewDidLoad];// UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1"] highlightedImage:[UIImage imageNamed:@"2"]]; UIImageView *imageV = [[UIImageView alloc] init]; imageV.frame = CGRectMake(100, 100, 150, 300); //設定是否允許使用者與控制項互動 imageV.userInteractionEnabled = YES; //設定圖片渲染顏色 imageV.tintColor = [UIColor greenColor]; NSMutableArray *arrayM = [NSMutableArray array]; for (int i=0; i<40; i++) { NSString *name = [NSString stringWithFormat:@"eat_%02d", i]; UIImage *image = [UIImage imageNamed:name]; [arrayM addObject:image]; } //設定圖片動畫數組 imageV.animationImages = arrayM; //設定播放次數 imageV.animationRepeatCount = 1; //設定總播放時間 imageV.animationDuration = arrayM.count * 0.08; //開始播放動畫 [imageV startAnimating]; [self.view addSubview:imageV];}- (void)startAnimating{ NSLog(@"%s", __func__);}- (void)stopAnimating{ NSLog(@"%s", __func__);}- (BOOL)isAnimating{ NSLog(@"%s", __func__); return YES;}