zoukankan      html  css  js  c++  java
  • 第三十九篇、NavBar动态隐藏、设置透明、毛玻璃效果

    1.动态隐藏

    - (void)viewDidLoad {
        [super viewDidLoad];
    
        if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
        
        //  1.tableView
        [self.view addSubview:self.tableView];
    }
    
    #pragma mark - 滑动隐藏导航栏
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        CGFloat offsetY = scrollView.contentOffset.y + _tableView.contentInset.top;//注意
        CGFloat panTranslationY = [scrollView.panGestureRecognizer translationInView:self.tableView].y;
        
        if (offsetY > 64) {
            if (panTranslationY > 0) { //下滑趋势,显示
                [self.navigationController setNavigationBarHidden:NO animated:YES];
            }
            else {  //上滑趋势,隐藏
                [self.navigationController setNavigationBarHidden:YES animated:YES];
            }
        }
        else {
            [self.navigationController setNavigationBarHidden:NO animated:YES];
        }
        
    //    NSLog(@"%lf %lf", [scrollView.panGestureRecognizer translationInView:self.tableView].y, offsetY);
    }

    2.设置透明

    [[[self.navigationController.navigationBar subviews] objectAtIndex:0] setAlpha:_alphaMemory];
  • 相关阅读:
    ASP.NET登录记住用户名
    .NET枚举类型转为List类型
    display:inline-block 去除间隙
    sublime text 3 常用快捷键 、常用插件
    使用背景图代码
    Photo Shop 修改、维护
    前端协作流程
    Photo Shop切图
    Photo Shop 设置
    Flex 弹性布局
  • 原文地址:https://www.cnblogs.com/HJQ2016/p/5917655.html
Copyright © 2011-2022 走看看