I have three images that I want to rotate in the background. Below is what I have so far. I want to have a class where I can hold all these UIImageViews and display them randomly in the background. I read about UIView and the frame method but I have no idea how to add them since it only takes in one frame.

Thus, I used NSArray to hold all the objects instead. The only problem now is when a new background appears, the old background doesn't disappear. Now do I remove the old background?

It would be great if someone can point me in the right direction.

Thanks!

```
@interface ViewController : UIViewController

@property (strong, nonatomic) NSArray *imageArray;
@property (strong, nonatomic) UIImageView *imageView;

- (IBAction)buttonPressed:(UIButton *)sender;

@end

```

// .m file

```
@implementation ViewController
@synthesize imageArray;
@synthesize imageView;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    imageView = [[UIImageView alloc] init];

    UIImage *image1 = [UIImage imageNamed:@"image1.png"];
    UIImage *image2 = [UIImage imageNamed:@"image2.png"];
    UIImage *image3 = [UIImage imageNamed:@"image3.png"];

    imageArray = [[NSArray alloc] initWithObjects:image1, image2, image3, nil];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)buttonPressed:(UIButton *)sender {

    NSUInteger index = arc4random_uniform(self.imageArray.count);
    [imageView setImage:[imageArray objectAtIndex:index]];

}
@end

```