gpt4 book ai didi

objective-c - UI 状态栏淡入淡出时间 iOS

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:50:52 24 4
gpt4 key购买 nike

我有一个应用程序,您可以在其中点击 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];
}
}

如有任何帮助或指导,我们将不胜感激。我的客户希望在星期二之前完成这项工作,或者找其他人来做这件事。我已将我的生命投入到这个应用程序中,如果您能帮助分享知识,请多多指教。谢谢

最佳答案

您可以将它包裹在动画 block 中。只需使用 setStatusBarHidden: 方法代替 setStatusBarHidden:withAnimation:

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

关于objective-c - UI 状态栏淡入淡出时间 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10163565/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com