你好,歡迎來到IOS教程網

 Ios教程網 >> IOS基礎知識 >> IOS基礎知識 >> IOS基礎-UIImageView

IOS基礎-UIImageView

編輯:IOS基礎知識

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;
}


 

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved