• <legend id='rWnB9'><style id='rWnB9'><dir id='rWnB9'><q id='rWnB9'></q></dir></style></legend>

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

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

      2. UINavigationBar 用动画改变 Tint 颜色

        时间:2023-06-11

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

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

                <tbody id='sYSJp'></tbody>

                  本文介绍了UINavigationBar 用动画改变 Tint 颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以通过动画更改色调以获得更平滑的效果?

                  Is it possible to change the tint with animation for a smoother effect?

                  这对我不起作用:

                  [UIView beginAnimations:nil context:nil];
                  [self.navigationController.navigationBar setTintColor:[UIColor greenColor]];
                  [UIView commitAnimations];
                  

                  我不确定是否甚至可以使用原生苹果组件,因为我猜他们将使用 CG 来生成渐变......只是想在我开始构建自己的解决方案之前找出答案......

                  I a not sure if it is even possible using native apple components as I guess they will be using CG to generate the gradient ... just want to find out before I'll start building my own solution ...

                  伙计们干杯:)

                  推荐答案

                  你不会相信我花了这么多时间才真正做到这一点;这让我很恼火,因为这不是 iOS 的常用功能,而且 tintColor 的过渡看起来很难看,而推动/弹出 viewController 的动画非常流畅.

                  You wouldn't believe the length I went through to actually make that possible; it annoyed me to no end that this isn't a stock iOS feature and that transition of tintColor look ugly while the animation to push/pop a viewController is so smooth.

                  有很多代码检查 when 是否消失,我什至编写了一个名为 PSPDFNavigationAppearanceSnapshot 的类来在弹出时保留导航状态.(我从很棒的 NimbusKit 得到这个想法)

                  There'a lot of code that checks when to fade, and I've even written a class called PSPDFNavigationAppearanceSnapshot to preserve the navigation state when being popped. (I got that idea from the awesome NimbusKit)

                  实际的动画很简单:

                  [self.navigationController.navigationBar.layer addAnimation:PSPDFFadeTransition() forKey:nil];
                  
                  CATransition *PSPDFFadeTransition(void) {
                      return PSPDFFadeTransitionWithDuration(0.25f);
                  }
                  
                  CATransition *PSPDFFadeTransitionWithDuration(CGFloat duration) {
                      CATransition *transition = [CATransition animation];
                      transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
                      transition.type = kCATransitionFade;
                      transition.duration = duration;
                      return transition;
                  }
                  

                  您可以进一步压缩该代码;它是从我的 iOS PDF 库 PSPDFKit 中截取的,我在各个地方使用淡入淡出,因此是辅助函数.

                  You can compact that code even more; it's a snipped from my iOS PDF library PSPDFKit and I use the fade in various places, thus the helper functions.

                  这篇关于UINavigationBar 用动画改变 Tint 颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将导航控制器添加到基于视图的应用程序中? 下一篇:以编程方式在 UIViewController 中添加 UINavigationController

                  相关文章

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

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

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

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