码迷,mamicode.com
首页 > 其他好文 > 详细

关于滑动改变Navigation颜色的方法

时间:2016-06-30 14:13:25      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

//状态栏透明
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.statusBarView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 20)];
    self.statusBarView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:self.statusBarView];
 
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSLog(@"offset---scroll:%f",self.tablView.contentOffset.y);
    UIColor *color=[UIColor redColor];
    CGFloat offset=scrollView.contentOffset.y;
    if (offset<0) {
        self.navigationController.navigationBar.backgroundColor = [color colorWithAlphaComponent:0];
        self.statusBarView.backgroundColor = [color colorWithAlphaComponent:0];
    }else {
        CGFloat alpha=1-((64-offset)/64);
        self.navigationController.navigationBar.backgroundColor=[color colorWithAlphaComponent:alpha];
        self.statusBarView.backgroundColor = [color colorWithAlphaComponent:alpha];
       
    }
}

关于滑动改变Navigation颜色的方法

标签:

原文地址:http://www.cnblogs.com/good-morning/p/5629660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!