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

//状态栏透明
    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];
       
    }
}
posted @ 2016-06-30 13:24  Good丶Morning  阅读(156)  评论(0编辑  收藏  举报