同时状态栏隐藏和视图转换

发布于 2024-12-07 05:00:25 字数 1377 浏览 0 评论 0原文

我想在我的应用程序中从“初始化屏幕”转换为“演示屏幕”。初始化屏幕的状态栏可见,但我希望演示屏幕使用全屏。我希望状态栏在初始化屏幕消失时消失,而不是在其之前或之后。

在我从初始化屏幕视图控制器的回调中,显示“准备运行”,我这样做:

[UIView transitionFromView: setupViewController.view toView: runViewController.view 
    duration: 1.0 options: UIViewAnimationOptionTransitionCurlUp 
    completion: ^(BOOL finished) {
        [[UIApplication sharedApplication] setStatusBarHidden: YES withAnimation: UIStatusBarAnimationSlide];
        }];

但是状态栏一直在那里,直到卷曲动画完成,然后它向上滑动。

所以我尝试了这个:

[UIView transitionFromView: setupViewController.view toView: runViewController.view 
    duration: 1.0 options: UIViewAnimationOptionTransitionCurlUp 
    completion: nil];
[[UIApplication sharedApplication] setStatusBarHidden: YES withAnimation: UIStatusBarAnimationSlide];

但是这样状态栏会在卷曲动画开始之前向上滑动。

所以我尝试了这个:

[UIView beginAnimations: @"whatever" context: nil];
[UIView setAnimationDuration: 1.0];
[UIApplication sharedApplication].statusBarHidden = YES;
[UIView transitionFromView: setupViewController.view toView: runViewController.view 
    duration: 1.0 options: UIViewAnimationOptionTransitionCurlUp completion: nil];
[UIView commitAnimations];

我得到了同步操作,但状态栏只是消失而不是向上滑动。

我真正想要的是状态栏与初始化屏幕一起卷曲(如果我使用卷曲或翻转,如果我使用翻转)以显示全屏,但我会满足于状态栏向上滑动在初始化屏幕卷起的 1.0 秒间隔期间。

感谢您的任何建议...

I would like to transition from an "initialization screen" to a "presentation screen" in my application. The initialization screen has the status bar visible but I want the presentation screen to use the full screen. I would like the status bar to disappear when the initialization screen does, not before or after it.

In my callback from the initialization screen view controller that says "ready to run" I do this:

[UIView transitionFromView: setupViewController.view toView: runViewController.view 
    duration: 1.0 options: UIViewAnimationOptionTransitionCurlUp 
    completion: ^(BOOL finished) {
        [[UIApplication sharedApplication] setStatusBarHidden: YES withAnimation: UIStatusBarAnimationSlide];
        }];

but with this the status bar is there until the curl-up animation completes, then it slides up.

So I tried this:

[UIView transitionFromView: setupViewController.view toView: runViewController.view 
    duration: 1.0 options: UIViewAnimationOptionTransitionCurlUp 
    completion: nil];
[[UIApplication sharedApplication] setStatusBarHidden: YES withAnimation: UIStatusBarAnimationSlide];

but with this the status bar slides up before the curl-up animation starts.

So I tried this:

[UIView beginAnimations: @"whatever" context: nil];
[UIView setAnimationDuration: 1.0];
[UIApplication sharedApplication].statusBarHidden = YES;
[UIView transitionFromView: setupViewController.view toView: runViewController.view 
    duration: 1.0 options: UIViewAnimationOptionTransitionCurlUp completion: nil];
[UIView commitAnimations];

and I get the simultaneous action but the status bar just fades away instead of sliding up.

What I would really like is for the status bar to curl-up with the initialization screen (if I am using curl-up or flip if I am using flip) to reveal the full screen but I will settle for the status bar to slide up during the 1.0 second interval that the initialization screen is curling up.

Thanks for any suggestions...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长亭外,古道边 2024-12-14 05:00:25

看来第三种方法可以按您的意愿工作,除非您使用了以下行:

[UIApplication sharedApplication].statusBarHidden = YES;

而不是:

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

它允许您设置向上滑动动画。

但是,我认为不可能将状态栏包含在卷曲动画中。

It seems the third method is working as you wish except you've used the line:

[UIApplication sharedApplication].statusBarHidden = YES;

instead of:

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

which allows you to set the slide up animation.

However, I don't think it's possible to include the status bar in the curl up animation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文