object-c---图片动画

初学object-c,纪录点点滴滴......

在viewController的viewDidLoad中,加入一下代码,在工程目录下存在1.png和2.png图片

@implementation ViewController

- (void)viewDidLoad 
{
    [super viewDidLoad];
    
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.view addSubview: imgView];
    
    imgView.animationImages=[NSArray arrayWithObjects:
                             [UIImage imageNamed:@“1.png”],
                             [UIImage imageNamed:@“2.png"],nil ];//1.png; 2.png
    imgView.animationDuration    = 1;                            //duration : 1s
    imgView.animationRepeatCount = 0;                            //repeat always
    
    [imgView startAnimating];                                    //start
}

你可能感兴趣的:(object-c---图片动画)