Domanda

I have an app where you tap a UIImageView and the buttons fade out and come back in. The Status bar does the same except it just comes in to quick. Is there a way to time its fade in to match my buttons timing ? Here is my .m file where the code for the buttons and status bar.

.m

- (void)viewDidLoad
{
////Loads UIImageView from URL
todaysWallpaper.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.inkdryercreative.com/daily/archive/mondays/images/062-mondays-960x640-A.jpg"]]]; 

_buttonsVisible = false;

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

  UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]    initWithTarget:self action:@selector(imageTapped:)];
  [todaysWallpaper addGestureRecognizer:tapGesture];
}

- (void)viewWillAppear:(BOOL)animated 
{
[super viewWillAppear:animated];

[[UIApplication sharedApplication] setStatusBarHidden:YES];
}

- (void)imageTapped:(UIGestureRecognizer *)sender {
float targetA = 0;
if(_buttonsVisible == NO) {
 targetA =1.0;
 } else {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(imageTapped:)  object:nil];
  [[UIApplication sharedApplication] setStatusBarHidden:YES];
  [[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
  [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];


}

[UIView beginAnimations:@"MoveAndStrech" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
homeButton.alpha = targetA;
infoButton.alpha = targetA;
saveButton.alpha = targetA;
tweetButton.alpha = targetA;
[UIView commitAnimations];
_buttonsVisible = !_buttonsVisible;

if(_buttonsVisible) {
[self performSelector:@selector(imageTapped:) withObject:nil afterDelay:100.0];
  [[UIApplication sharedApplication] setStatusBarHidden:NO ];

  [[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
}
}

Any help or guidance would be appreciated greatly. My client wants to have this done by tuesday or find someone else to do this. I have put my life into this app so please if you can help share the knowledge. thanks

È stato utile?

Soluzione

You could wrap it in the animation block. Just use the setStatusBarHidden: method instead of setStatusBarHidden:withAnimation:

[UIView beginAnimations:@"foo" context:nil];
[UIView setAnimationDuration:1.0];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[UIView commitAnimations];

Altri suggerimenti

Try setting the status bar using the below code:

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

You can try this it is the single line code for all iOS devices:

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

Hope it helps..

What you could do is create your own NavigationBar (don't use the UINavigationController's UINavigationBar) - You can then customize it and assign it easily animatable properties such as alpha.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top