先生,我需要在我的导航栏上设置背景图像我已经在这里尝试了解决方案,我无法得到它。请指导我
-(void)edditingNavigationBar{
UIImageView *titleView=[[UIImageView alloc]initWithFrame:CGRectMake(138, 20, 35, 29)];
[titleView setImage:[UIImage imageNamed:@"addVehicle"]];
titleView.contentMode=UIViewContentModeScaleAspectFit;
self.navigationItem.titleView=titleView;
if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
UIImage *image = [UIImage imageNamed:@"head_bg"] ;
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];}
}
这就是它现在的样子。
当我根据320 * 44的导航栏的高度和宽度调整图像大小时,它看起来像这样