- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
CGFloat offSetY = scrollView.contentOffset.y;
if (offSetY < 64.0) {
CGFloat alpha = offSetY / 64.0;
[self.navigationController.navigationBar setBackgroundImage:[self imageWithColor:[UIColor colorWithRed:0 green:0 blue:1.0 alpha:alpha]] forBarMetrics:UIBarMetricsDefault];
}else{
[self.navigationController.navigationBar setBackgroundImage:[self imageWithColor:[UIColor colorWithRed:0 green:0 blue:1.0 alpha:0]] forBarMetrics:UIBarMetricsDefault];
}
}
-(UIImage *)imageWithColor:(UIColor *)color
{
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}