//
自定义导航栏视图
@property
(
nonatomic
,
strong
)
UIView
* naviView;
viewDidLoad中:
if
([
self
respondsToSelector
:
@selector
(setEdgesForExtendedLayout:)])
{
[ self setEdgesForExtendedLayout : UIRectEdgeNone ];
{
[ self setEdgesForExtendedLayout : UIRectEdgeNone ];
}
self
.
naviView
= [[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
YJScreenWidth
,
64
)];
self . naviView . backgroundColor = THEME_Color ;
[ self . view addSubview : self . naviView ];
self . naviView . backgroundColor = THEME_Color ;
[ self . view addSubview : self . naviView ];
[self.view bringSubviewToFront:self.naviView];
- (
void
)viewWillAppear:(
BOOL
)animated
{
[ super viewWillAppear :animated];
[ self . navigationController setNavigationBarHidden : YES animated :animated];
}
- ( void )viewWillDisappear:( BOOL )animated
{
[ super viewWillDisappear :animated];
[ self . navigationController setNavigationBarHidden : NO animated :animated];
{
[ super viewWillAppear :animated];
[ self . navigationController setNavigationBarHidden : YES animated :animated];
}
- ( void )viewWillDisappear:( BOOL )animated
{
[ super viewWillDisappear :animated];
[ self . navigationController setNavigationBarHidden : NO animated :animated];
}
#pragma mark - scrollViewDelegate
- ( void )scrollViewDidScroll:( UIScrollView *)scrollView
{
CGFloat alpha = scrollView. contentOffset . y / 100 ;
if (alpha >= 1 ) {
alpha = 1 ;
} else if (alpha <= 0 )
{
alpha = 0 ;
}
self . naviView . backgroundColor = [ THEME_Color colorWithAlphaComponent :alpha];
- ( void )scrollViewDidScroll:( UIScrollView *)scrollView
{
CGFloat alpha = scrollView. contentOffset . y / 100 ;
if (alpha >= 1 ) {
alpha = 1 ;
} else if (alpha <= 0 )
{
alpha = 0 ;
}
self . naviView . backgroundColor = [ THEME_Color colorWithAlphaComponent :alpha];
}