<i id='xBb4t'><tr id='xBb4t'><dt id='xBb4t'><q id='xBb4t'><span id='xBb4t'><b id='xBb4t'><form id='xBb4t'><ins id='xBb4t'></ins><ul id='xBb4t'></ul><sub id='xBb4t'></sub></form><legend id='xBb4t'></legend><bdo id='xBb4t'><pre id='xBb4t'><center id='xBb4t'></center></pre></bdo></b><th id='xBb4t'></th></span></q></dt></tr></i><div id='xBb4t'><tfoot id='xBb4t'></tfoot><dl id='xBb4t'><fieldset id='xBb4t'></fieldset></dl></div>
    <legend id='xBb4t'><style id='xBb4t'><dir id='xBb4t'><q id='xBb4t'></q></dir></style></legend>

    <small id='xBb4t'></small><noframes id='xBb4t'>

        <bdo id='xBb4t'></bdo><ul id='xBb4t'></ul>
      <tfoot id='xBb4t'></tfoot>

        在透明导航栏到半透明之间转换

        时间:2023-06-10
          • <bdo id='QjbvQ'></bdo><ul id='QjbvQ'></ul>

              <tfoot id='QjbvQ'></tfoot>

              <small id='QjbvQ'></small><noframes id='QjbvQ'>

                    <tbody id='QjbvQ'></tbody>
                  <legend id='QjbvQ'><style id='QjbvQ'><dir id='QjbvQ'><q id='QjbvQ'></q></dir></style></legend>
                • <i id='QjbvQ'><tr id='QjbvQ'><dt id='QjbvQ'><q id='QjbvQ'><span id='QjbvQ'><b id='QjbvQ'><form id='QjbvQ'><ins id='QjbvQ'></ins><ul id='QjbvQ'></ul><sub id='QjbvQ'></sub></form><legend id='QjbvQ'></legend><bdo id='QjbvQ'><pre id='QjbvQ'><center id='QjbvQ'></center></pre></bdo></b><th id='QjbvQ'></th></span></q></dt></tr></i><div id='QjbvQ'><tfoot id='QjbvQ'></tfoot><dl id='QjbvQ'><fieldset id='QjbvQ'></fieldset></dl></div>
                  本文介绍了在透明导航栏到半透明之间转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 Apple 最近发布的 Remote 应用程序中,我注意到导航栏的行为方式是独一无二的,我无法重现它.弹出 Now Playing 视图控制器时,Now Playing 视图控制器的导航栏保持透明,库视图控制器的导航栏也保持半透明(屏幕截图 1).我试图弄清楚他们是使用两个导航控制器还是只使用一个.就我个人而言,我觉得他们只使用了一个,原因有两个:(1)启用了交互式弹出手势;(2) 当您按下库视图控制器中的正在播放"按钮时,就在正在播放的屏幕完成推送视图控制器"动画之前,导航栏变得透明(屏幕截图 2).这是我在推送视图控制器(将导航栏设置为透明)时遇到的行为.所以我的问题是:Apple 如何将两个视图控制器的两个导航栏都呈现为单独的(如屏幕截图 1 所示),即使是栏按钮、导航标题等......在切换时也是 100% 的不透明度(通常在推动/弹出前一个视图控制器的按钮和标题会随着新控制器的被推动而消失).我已经尝试在两个视图控制器中使用 viewDidAppearviewWillAppear 中的条形色调颜色,但无法重现相同的行为,并且无法防止条形按钮褪色.

                  In Apple's recently released Remote app I noticed the way in which the navigation bar behaves is unique and I haven't been able reproduce it. When popping the Now Playing view controller the navigation bar remains transparent for the Now Playing view controller and the navigation bar for the library view controller also stays translucent (Screenshot 1). I'm trying to figure out if they are using two navigation controllers or only one. Personally I feel they're using just one for two reasons (1) the interactive pop gesture is enabled; (2) when you press the 'Now Playing' button in the library view controller, just before the now playing screen has finished 'push view controller' animation the navigation bar becomes transparent (Screenshot 2). This is the behaviour I experience when pushing my view controller (which sets the navigation bar to transparent). So my question is: How does Apple present both navigation bars of the two view controllers as if they were individual (as with Screenshot 1), even the bar buttons, navigation title etc... are 100% in opacity when switching (usually when pushing/popping the buttons and titles of the previous view controller fade as the new controller is being pushed). I've tried playing around with the bar tint colour in viewDidAppear and viewWillAppear in both view controllers but cannot reproduce the same behaviour, and cannot prevent the bar buttons from fading.

                  天哪,我希望我已经很好地解释了这一点,我只是想一想就感到困惑!

                  Gosh I hope I've explained this well, I get confused just thinking about it!

                  屏幕截图 1(弹出):

                  Screenshot 1 (Popping):

                  屏幕截图 2(推送):

                  Screenshot 2 (Pushing):

                  推荐答案

                  我刚刚下载了应用程序以确保.使用了两个不同的导航栏.您可以使用交互式弹出手势看到这一点.注意底部视图控制器上的导航栏是如何滑入和滑出的.在正常的推送和弹出转换期间,导航项只是在现有栏上淡入和淡出,而栏是静止的.这是在推送正在播放的视图控制器之前发生的情况.

                  I just downloaded the application to make sure. Two different navigation bars are used. You can see this by using the interactive pop gesture. Notice how the navigation bar on the bottom view controller slides in and out. During normal push and pop transitions, the navigation items just fade in and out on the existing bar, while the bar is stationary. This is what happens up until the point where the now playing view controller is pushed.

                  如果你快速看,在正在播放的视图控制器动画期间,你可以看到底部导航栏消失了.

                  If you look quickly, during the now playing view controller animation, you can see the bottom navigation bar disappear.

                  根据我对 UIKit 行为的经验以及我在应用中看到的情况,我认为会发生以下情况:

                  From my experience with UIKit behavior and what I see in the app, here is what I think happens:

                  album_vc = 底部,列表视图控制器nowplaying_vc = 顶视图控制器

                  album_vc = the bottom, list view controller nowplaying_vc = the top view controller

                  • nowplaying_vcviewWillAppear:

                  • 使用 [self.navigationController setNavigationBarHidden:YES animated:YES]; 将导航栏设置为隐藏.由于这是在动画块中,这将使导航栏在推送动画期间滑出.
                  • Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; 很确定,因为注意状态栏样式的过渡没有动画.它只是变成白色.
                  • Set the navigation bar to hidden using [self.navigationController setNavigationBarHidden:YES animated:YES];. Since this is in animation block, this will make the navigation bar slide out during the push animation.
                  • Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; Pretty sure about this, because notice there is no animation in the transition of the status bar styles. It just becomes white.

                  nowplaying_vcviewWillDisappear:

                  • 使用 [self.navigationController setNavigationBarHidden:NO animated:YES]; 将导航栏设置为显示.由于这是在动画块中,这将使导航栏在弹出动画期间滑入.
                  • 设置 [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; 再次注意,在交互式弹出手势期间,状态栏只是在没有动画的情况下发生变化.
                  • Set the navigation bar to shown using [self.navigationController setNavigationBarHidden:NO animated:YES];. Since this is in animation block, this will make the navigation bar slide in during the pop animation.
                  • Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; Again, notice how during interactive pop gesture, the status bar just changes with no animation.

                  要实现nowplaying_vc导航栏的透明外观,可以使用空图片([UIImage alloc])和setBackgroundImage:forBarPosition:barMetrics:.

                  To achieve the transparent look of the navigation bar of nowplaying_vc, you can use an empty image ([UIImage alloc]) with setBackgroundImage:forBarPosition:barMetrics:.

                  由于应用程序不旋转,我们无法确定 nowplaying_vc 上的导航栏是另一个导航控制器的一部分,还是只是顶部位置为 的导航栏UIBarPositionTopAttached.据我们所知,那里甚至没有导航栏,只有一个后退 V 形图像视图(后退栏按钮由一个图像视图和一个按钮组成).

                  Since the application does not rotate, we can't be sure if the navigation bar on nowplaying_vc is part of another navigation controller or just a navigation bar on the top with a position of UIBarPositionTopAttached. For all we know, there isn't even a navigation bar there but just a back chevron image view (back bar button is comprised of an image view and a button).

                  我认为 viewWillAppear:viewWillDisappear: 中的状态栏样式发生了变化,因为在交互式弹出手势期间存在不自然的感觉.我建议使用动画过渡,或者更好的是,使用新的基于视图控制器的状态栏样式,系统会自行对过渡进行动画处理.

                  I think the status bar style is changed in viewWillAppear: and viewWillDisappear: due to the unnatural feel there is during interactive pop gesture. I would recommend using an animated transition, or even better, use the new view controller-based status bar style, which the system animates transitions by itself.

                  现代 API 更新:

                  您应该使用 animateAlongsideTransition:completion:animateAlongsideTransitionInView:animation:completion: API,而不是依赖 viewWillAppear:viewWillDisappear:.

                  You should use the animateAlongsideTransition:completion: or animateAlongsideTransitionInView:animation:completion: API, rather than relying on the implicit animations of viewWillAppear: and viewWillDisappear:.

                  这篇关于在透明导航栏到半透明之间转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:iOS11 中奇怪的 uitableview 行为.带有导航推送动画的单元格向上滚动 下一篇:自定义 UINavigationController UIToolbar 背景图片

                  相关文章

                  1. <legend id='WVEP5'><style id='WVEP5'><dir id='WVEP5'><q id='WVEP5'></q></dir></style></legend>

                    <small id='WVEP5'></small><noframes id='WVEP5'>

                      <tfoot id='WVEP5'></tfoot>
                        <bdo id='WVEP5'></bdo><ul id='WVEP5'></ul>
                      <i id='WVEP5'><tr id='WVEP5'><dt id='WVEP5'><q id='WVEP5'><span id='WVEP5'><b id='WVEP5'><form id='WVEP5'><ins id='WVEP5'></ins><ul id='WVEP5'></ul><sub id='WVEP5'></sub></form><legend id='WVEP5'></legend><bdo id='WVEP5'><pre id='WVEP5'><center id='WVEP5'></center></pre></bdo></b><th id='WVEP5'></th></span></q></dt></tr></i><div id='WVEP5'><tfoot id='WVEP5'></tfoot><dl id='WVEP5'><fieldset id='WVEP5'></fieldset></dl></div>