我有一个应用程序,您可以在其中点击 UIImageView,然后按钮淡出并重新出现。状态栏的作用相同,只是它只是快速进入。有没有办法让它淡入以匹配我的按钮时间?这是我的 .m 文件,其中包含按钮和状态栏的代码。
.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];
}
}
任何帮助或指导将不胜感激。我的客户希望在星期二之前完成这项工作,或者找其他人来完成这项工作。我已经把我的生命投入到这个应用程序中,所以如果你能帮助分享知识,请。谢谢