- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"offset---scroll:%f",scrollView.contentOffset.y);
UIColor *color=blue_jump_color; //blue_jump_color这个是定义的颜色宏
if (scrollView == self.tableView) { //这一步是为了保证滑动tableview时候才让导航栏变色
CGFloat offset=scrollView.contentOffset.y; //获取y值
if (offset<=0) {
_navBackV.backgroundColor = [color colorWithAlphaComponent:0]; // _navBackV是导航栏
}else if(offset>0){
CGFloat alpha=1-((64-offset)/64);
_navBackV.backgroundColor = [color colorWithAlphaComponent:alpha];
}
}
}
网友评论