pragma mark -- 修改导航栏渐变色 colorWithAlphaComponent防止污染子控件透明度
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat alpha = scrollView.contentOffset.y/100;
if (alpha > 1) {
alpha = 1;
}else if (alpha<0){
UIColor *color = [UIColor colorWithHexString:@"#ff8833"];
self.navigationBar.backgroundColor = [color colorWithAlphaComponent:-alpha];
}else{
UIColor *color = [UIColor colorWithHexString:@"#ff8833"];
self.navigationBar.backgroundColor = [color colorWithAlphaComponent:alpha];
}
}
网友评论