- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[self buttonImageFromColor:[UIColor colorWithHex:@"#ffffff"]] forBarMetrics:UIBarMetricsDefault];
// [self.navigationController.navigationBar setBackgroundImage:[self buttonImageFromColor:[UIColor colorWithHex:@"#ffffff"]] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc]init]];
}
/**
* 生成一张纯色图片
*/
- (UIImage *)buttonImageFromColor:(UIColor *)color{
CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}