IOS,圖片切換動畫

_Vi = [[UIView alloc]initWithFrame:CGRectMake(100, 200, 200, 200)];
    //定義數組,存放全部圖片對象
    NSArray *images=[NSArray arrayWithObjects:[UIImage imageNamed:@"image003.jpg"],[UIImage imageNamed:@"image004.jpg"], nil];
    //        //定義結構體,方塊大小
    //        CGRect frame=CGRectMake(100, 100, 200, 200);
    //初始化圖像視圖對象,大小是frame
    _imageView = [[UIImageView alloc] initWithFrame:_Vi.bounds];
    //imageView的動畫圖片是數組images
    _imageView.animationImages = images;
    //按照原始比例縮放圖片,保持縱橫比
    _imageView.contentMode = UIViewContentModeScaleAspectFit;
    //切換動做的時間0.5秒,來控制圖像顯示的速度有多快,
    _imageView.animationDuration = 0.5;
    //動畫的重複次數,想讓它無限循環就賦成0
    _imageView.animationRepeatCount = 0;
    //開始動畫
    [_imageView startAnimating];
    //添加控件
    [_Vi addSubview:_imageView];
    [self.view addSubview:_Vi];
相關文章
相關標籤/搜索