滑动的scrollowview的导航渐变

时间:2024-01-02 11:35:50

CGFloat offsetY = scrollView.contentOffset.y;

CGFloat alpha = 0;

if (offsetY >= 64) {

alpha=((offsetY-64)/64 <= 1.0 ? (offsetY-64)/64:1);

[self.navigationController.navigationBar lt_setBackgroundColor:[[UIColor appNavigationBarColor] colorWithAlphaComponent:alpha]];

}else{

[self.navigationController.navigationBar lt_setBackgroundColor:[UIColor clearColor]];

}