此範例先將動畫要用之圖片複製近xcode中,

接著使用一個array並存放圖片,

之後創建一個imageView物件顯示動畫窗格,

再透過[imageView startAnimating]此方法播放動畫, 程式碼如下

NSArray *animationImages = [NSArrayarrayWithObjects:
                           [UIImageimageNamed:@"1.jpg"],
                           [UIImage imageNamed:@"2.jpg"],
                           [UIImage imageNamed:@"3.jpg"],
                           [UIImage imageNamed:@"4.jpg"],nil];


    UIImageView *imageView = [[UIImageViewalloc] initWithFrame:CGRectMake(0,0,150,150)];
    imageView.animationImages = animationImages ;
    imageView.animationRepeatCount = 0; 
    imageView.animationDuration= 12.0;
    [imageView startAnimating];

    [self.view addSubview:imageView];


arrow
arrow

    Will 發表在 痞客邦 留言(0) 人氣()