I have a scrollView with paging enabled. When i start to drag to the next page i want to text in my navigationBar smoothly fade out. I do it with delegate method:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
I calculate the percent of dragging with:
CGFloat percentDragging = 1 - fmodf(scrollView.contentOffset.x,self.view.frame.size.width)/self.view.frame.size.width;
And this return right values.
So: I try to set:
self.navigationController.navigationBar.titleView.alpha = percentDragging
but it didn't work.
I solved the problem by:
((UIView*)[[self.navigationController.navigationBar subviews] objectAtIndex:1]).alpha = percentDragging;
But this is ugly, crude, dangerous solution. There is a better way?
Setting the titleView
's alpha didn't work because that doesn't give you access to the default navigation-bar title label—it only has a value when you've set one. I think what you'll have to do here is set a custom titleView yourself, containing a UILabel with font/shadow/etc. set to match the standard style, and fade that label in and out with your transition.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.