zoukankan      html  css  js  c++  java
  • 动态 改变导航栏透明度

    #pragma mark - 实现代理方法  UINavigationBarDelegate 改变导航栏的颜色等功能

    - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated

    {

        self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

        UIImage *image = [UIImage imageNamed:@"128"];

        [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];

        UIView *view = self.navigationController.navigationBar.subviews[0];

        

        if (_tableView.contentOffset.y <= - 64) {

            

            self.navigationController.navigationBar.translucent = YES;

            view.alpha = 0;

        } else if(_tableView.contentOffset.y > - 64 && _tableView.contentOffset.y <= 0) {

        

            self.navigationController.navigationBar.translucent = YES;

                view.alpha = (64 - fabs(_tableView.contentOffset.y)) / 200.0f;//绝对值

        } else {

            

            view.alpha = (_tableView.contentOffset.y + 128) / 200.0f;

            if (view.alpha >= 1) {

                self.navigationController.navigationBar.translucent = NO;

            }

            

        }

        DLog(@"%f", _tableView.contentOffset.y);

        

    }

  • 相关阅读:
    64位系统上32位进程拷贝文件到System32目录时的重定向
    mac osx上为qt应用生成debug symbol
    c++正则表达式模板库GRETA的使用
    win驱动安装记录
    QWidget标题栏双击事件
    mac上的应用提权
    js初级DOM&BOM知识点总结
    js数组遍历
    angular.js小知识总结
    Node.js
  • 原文地址:https://www.cnblogs.com/iOS-mt/p/4251479.html
Copyright © 2011-2022 走看看