Skip to content
Search

IOS:UIImageView

lastmod 2018-08-17created 2014-02-246 edits

Frame Animation

To show images as frames, use the animationImages property.

UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(40, 30, 200, 200)];
imgView.animationImages = [NSArray arrayWithObjects:
                           [UIImage imageNamed:@"img_satelite01.png"],
                           [UIImage imageNamed:@"img_satelite02.png"],
                           [UIImage imageNamed:@"img_satelite03.png"],
                           [UIImage imageNamed:@"img_satelite04.png"],
                           nil];
[imgView setImage:[UIImage imageNamed:@"img_satelite01.png"]];
imgView.animationRepeatCount = INFINITY; // Same 0 value.
imgView.animationDuration = 1;
[self.view addSubview:imgView];
[imgView release];

[imgView startAnimating];
// ...
[imgView stopAnimating];

Sample code

How to add an image to a UIImageView.

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width,height)];
UIImage *image = [UIImage imageNamed:@"image.png"];
imageView.image = image;
[self.view addSubview:imageView];

See also

Favorite site