iOS 控件

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

2017-06-12  本文已影响41人  姓吕名立字小布2

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;

}

}

上一篇下一篇

猜你喜欢

热点阅读