Wednesday, 15 June 2016

Image View with Array of Images in iOS - Objective C

1) Create Single View Application
2) Go to ViewController.h, Add below code

@interface ViewController : UIViewController
{
   UIImageView *imgView;
    
}

@end



3) Go to view controller.m  Add below code

- (void)viewDidLoad
{
    
    imgView=[[UIImageView alloc]init];
    imgView.frame=CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height/2 );
    NSArray *imgArray=[NSArray arrayWithObjects:
                       [UIImage imageNamed:@"1.jpeg"],
                       [UIImage imageNamed:@"2.jpeg"],
                       [UIImage imageNamed:@"3.jpeg"],
                       [UIImage imageNamed:@"4.jpeg"],
                       nil];
    imgView.animationImages=imgArray;
    imgView.animationDuration=4.0;
    imgView.animationRepeatCount=0;
    [imgView startAnimating];
    [self.view addSubview:imgView];
    
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

}



No comments:

Post a Comment