Tuesday, January 27, 2015

Animate images in UIImageView

-(void)addImageViewWithAnimation{ 

   UIImageView *imgview = [[UIImageView alloc]      
    initWithFrame:CGRectMake(10, 10, 300, 400)]; // set an animation 

   imgview.animationImages = [NSArray arrayWithObjects: [UIImage 
       imageNamed:@"AppleUSA1.jpg"], [UIImage   
       imageNamed:@"AppleUSA2.jpg"], nil]; 

   imgview.animationDuration = 4.0; 
   imgview.contentMode = UIViewContentModeCenter; 
   [imgview startAnimating]; 
   
   [self.view addSubview:imgview]; 

Hide status bar programmatically with animation


-(void)hideStatusbar{ 

      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; 

      [UIView beginAnimations:@"Statusbar hide" context:nil]; 
      [UIView setAnimationDuration:0.5]; 

      [self.view setFrame:CGRectMake(0, 0, 320, 480)]; 
      [UIView commitAnimations]; 


- (void)viewDidLoad { 
      [super viewDidLoad]; // hideStatusbar called after 2 seconds 
      
      [self performSelector:@selector(hideStatusbar) withObject:nil 
         afterDelay:2.0];