//正在滚动
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
float offset_Y = scrollView.contentOffset.y;
NSLog(@"%f",scrollView.contentOffset.y);
UIView *barView = [self.navigationController.view viewWithTag:1000];
if (offset_Y == -20) {
//colorWithAlphaComponent 只改变父视图的的透明度,不会改变子View的透明度
barView.backgroundColor = [[UIColor yellowColor] colorWithAlphaComponent:0.0];
}else if(offset_Y >= 160){
barView.alpha = 1.0;
}else{
barView.backgroundColor = [[UIColor yellowColor] colorWithAlphaComponent:(offset_Y) / 160];
}
}
时间: 2024-10-27 18:14:15