Friday, July 25, 2014

Waiting label strip on top position of device with animation

 //Show an Wait indicator
 [self showHelpLabel];


#pragma mark -
#pragma mark showHelpLabel
-(void)showHelpLabel {  // Show instructions
    
    infoLabel = [[UILabel alloc] init];
    infoLabel.text = [NSString stringWithFormat:NSLocalizedString(@"PleaseWait", @"")];
    
    //Check OS version and set image for Toolbar button
    reqSysVer = @"7.0";
    currSysVer = [[UIDevice currentDevice] systemVersion];
    
    //Check OS version and set image for Toolbar button
    if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) {        
        [infoLabel setFrame:CGRectMake(0, 60,self.mapView.frame.size.width ,50)];
    }
    else {
        [infoLabel setFrame:CGRectMake(0, 0,self.mapView.frame.size.width ,50)];
    }
    
    infoLabel.numberOfLines =2;
    
    [infoLabel setBackgroundColor:[UIColor blackColor]];
    infoLabel.textAlignment = UITextAlignmentCenter;
    [infoLabel setTextColor:[UIColor whiteColor]];
    infoLabel.autoresizesSubviews = TRUE;
    infoLabel.autoresizingMask=UIViewAutoresizingFlexibleWidth;
    [self.mapView  addSubview:infoLabel];
    
    [UIView beginAnimations:@"fade" context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(reverseAnimation)];
infoLabel.alpha = 0.0;
infoLabel.alpha = 1.0;
    
[UIView commitAnimations];
}


#pragma mark -
#pragma mark reverseAnimation
-(void)reverseAnimation {
    
    [UIView beginAnimations:@"fade" context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
    
    [UIView setAnimationDidStopSelector:@selector(removeLabel)];
    
infoLabel.alpha = 1.0;
infoLabel.alpha = 0.0;
    
[UIView commitAnimations];
}



#pragma mark -
#pragma mark HelpLabel
-(void)removeLabel { // Remove instructions
    
    [infoLabel removeFromSuperview];
}


No comments:

Post a Comment