iOS滑动tableView来改变导航栏的颜色-1
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[self.navigationController.navigationBar setBackgroundImage:[self imageWithBgColor:[UIColor colorWithRed:self.tableView.contentOffset.y/255 green:255/255 blue:255/255 alpha:1]] forBarMetrics:UIBarMetricsDefault];
NSLog(@"contentOffset====%f",self.tableView.contentOffset.y);
if (self.tableView.contentOffset.y < 0) {
self.Myview .hidden = YES;
}
}
-(UIImage *)imageWithBgColor:(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 *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}