美文网首页iOS 控件
IOS实现随着页面滑动改变导航条透明度的方法

IOS实现随着页面滑动改变导航条透明度的方法

作者: 姓吕名立字小布2 | 来源:发表于2017-06-12 19:43 被阅读41次

IOS实现随着页面滑动改变导航条透明度的方法

1.实现代理UIScrollViewDelegate

2.

#pragma mark -- UIScrollDelegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

if (scrollView.contentOffset.y < 0) {

self.scrollView.contentOffset = CGPointMake(0, 0);

}

if (scrollView.contentOffset.y > 100) {

[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [DHCText3Color colorWithAlphaComponent:(scrollView.contentOffset.y/100)],NSFontAttributeName:[UIFont systemFontOfSize:15]}];

self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[self getImageWithAlpha:scrollView.contentOffset.y/100]];

_lineView = [self getLineViewInNavigationBar:self.navigationController.navigationBar];

_lineView.hidden = NO;

}

if (scrollView.contentOffset.y < 100) {

[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [DHCText3Color colorWithAlphaComponent:(scrollView.contentOffset.y/100)],NSFontAttributeName:[UIFont systemFontOfSize:15]}];

self.navigationController.navigationBar.barTintColor = [UIColor colorWithPatternImage:[self getImageWithAlpha:scrollView.contentOffset.y/100]];

_lineView = [self getLineViewInNavigationBar:self.navigationController.navigationBar];

_lineView.hidden = YES;

}

}

相关文章

网友评论

    本文标题:IOS实现随着页面滑动改变导航条透明度的方法

    本文链接:https://www.haomeiwen.com/subject/hwfrqxtx.html