1、导航栏开始时是没有导航栏的感觉,往上滚动后又出现导航栏,采用下面的方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat minAlphaOffset = - 88;
CGFloat maxAlphaOffset = 200;
CGFloat offset = scrollView.contentOffset.y;
CGFloat alpha;
if (offset <= 0) {
alpha = 0.0;
} else {
alpha = (offset - minAlphaOffset) / (maxAlphaOffset - minAlphaOffset);
}
UIView *barImageView = self.navigationController.navigationBar.subviews.firstObject;
barImageView.alpha = alpha;
}
//设置透明导航栏
UIView *barImageView = self.navigationController.navigationBar.subviews.firstObject;
barImageView.alpha = 0.0;
原文地址:https://www.cnblogs.com/xiaonizicome/p/10436359.html
时间: 2024-10-06 19:46:24