zoukankan      html  css  js  c++  java
  • KVO监测tableView的滑动

    首先添加监听者

    [self.tableView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];

    监听属性值发生改变时回调

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context{
        
        NSLog(@"%f",self.tableView.contentOffset.y);
        
        CGFloat offset = self.tableView.contentOffset.y;
        CGFloat delta = offset/64.f + 0.5;
        
        NSLog(@"===============%f",offset/64.f);
        
        delta = MAX(0, delta);
        self.navigationController.navigationBar.alpha = MIN(delta,1);
    }

    设置导航栏背景色

    #define RGBACOLOR(r, g, b, a)   [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
    
    self.navigationController.navigationBar.barTintColor = RGBACOLOR(36, 188, 61, 10);
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barStyle = UIStatusBarStyleDefault;
  • 相关阅读:
    使用阿里云ECS安装HDFS的小问题
    退役回忆录嘤嘤嘤
    2018 ICPC北京 H ac自动机
    Educational Codeforces Round 54 (Rated for Div. 2) DE
    sa learning
    网络流learning
    Python模块logging
    Python模块unittest
    Linux /dev/shm
    Shell 字符串操作
  • 原文地址:https://www.cnblogs.com/h-tao/p/5054238.html
Copyright © 2011-2022 走看看