1~修改UINavigationController title 字体的颜色和大小
方法一
//UIColor * cc = [UIColorwhiteColor];
NSDictionary * dic = [NSDictionarydictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,[UIFontsystemFontOfSize:20],UITextAttributeFont,nil];
self.navigationController.navigationBar.titleTextAttributes = dic;
方法二
UILabel *t = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
t.font = [UIFont systemFontOfSize:12];
t.textColor = [UIColor whiteColor];
t.backgroundColor = [UIColor clearColor];
t.textAlignment = UITextAlignmentCenter;
t.text = @"test";
self.navigationItem.titleView = t;
2~自定义修改UINavigationController 上的Button
UIButton *backBtn=[[UIButtonalloc]initWithFrame:CGRectMake(0, 0, 26, 26)];
NSString *path=[[NSBundlemainBundle]pathForResource:@"Nav_back"ofType:@"png"];
UIImage *img=[UIImageimageWithContentsOfFile:path];
[backBtn setBackgroundImage:imgforState:UIControlStateNormal];//
NSString *pathhigh=[[NSBundlemainBundle]pathForResource:@"Nav_back"ofType:@"png"];
UIImage *imghigh=[UIImageimageWithContentsOfFile:pathhigh];
[backBtn setBackgroundImage:imghighforState:UIControlStateHighlighted];
[backBtn addTarget:selfaction:@selector(BtnbackPress:)forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backBar=[[UIBarButtonItemalloc]initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem=backBar;
UIButton *btn1 = [UIButtonbuttonWithType:UIButtonTypeCustom];
btn1.frame=CGRectMake(0, 0, 74, 28);
btn1.tag = 7;
[btn1 setTitle:@"全部"forState:UIControlStateNormal];
btn1.titleLabel.font = [UIFontsystemFontOfSize:13];
[btn1 setTitleColor:[UIColorwhiteColor]forState:UIControlStateNormal];
[btn1 setTitleColor:[PublicClasscolorFromHexRGB:@"ff476a"]forState:UIControlStateSelected];
NSString *path1=[[NSBundlemainBundle]pathForResource:@"DoctorLeft"ofType:@"png"];
UIImage *img1=[UIImageimageWithContentsOfFile:path1];
[btn1 setBackgroundImage:img1forState:UIControlStateNormal];
NSString *path1_S=[[NSBundlemainBundle]pathForResource:@"DoctorLeft_select"ofType:@"png"];
UIImage *img1_S=[UIImageimageWithContentsOfFile:path1_S];
[btn1 setBackgroundImage:img1_SforState:UIControlStateSelected];
[btn1 addTarget:selfaction:@selector(BtnAllExpertListPress:)forControlEvents:UIControlEventTouchUpInside];
[btn1setSelected:YES];
UIButton *btn2 = [UIButtonbuttonWithType:UIButtonTypeCustom];
btn2.frame=CGRectMake(74, 0, 74, 28);
btn2.tag = 8;
[btn2 setTitle:@"本地"forState:UIControlStateNormal];
btn2.titleLabel.font = [UIFontsystemFontOfSize:13];
[btn2 setTitleColor:[UIColorwhiteColor]forState:UIControlStateNormal];
[btn2 setTitleColor:[PublicClasscolorFromHexRGB:@"ff476a"]forState:UIControlStateSelected];
NSString *path2=[[NSBundlemainBundle]pathForResource:@"DoctorCenter"ofType:@"png"];
UIImage *img2=[UIImageimageWithContentsOfFile:path2];
[btn2 setBackgroundImage:img2forState:UIControlStateNormal];
NSString *path2_S=[[NSBundlemainBundle]pathForResource:@"DoctorCenter_select"ofType:@"png"];
UIImage *img2_S=[UIImageimageWithContentsOfFile:path2_S];
[btn2 setBackgroundImage:img2_SforState:UIControlStateSelected];
[btn2 addTarget:selfaction:@selector(BtnLocalExpertListPress:)forControlEvents:UIControlEventTouchUpInside];
UIButton *btn3 = [UIButtonbuttonWithType:UIButtonTypeCustom];
btn3.frame=CGRectMake(148, 0, 74, 28);
btn3.tag = 9;
btn3.titleLabel.font = [UIFontsystemFontOfSize:13];
[btn3 setTitle:@"权威"forState:UIControlStateNormal];
[btn3 setTitleColor:[UIColorwhiteColor]forState:UIControlStateNormal];
[btn3 setTitleColor:[PublicClasscolorFromHexRGB:@"ff476a"]forState:UIControlStateSelected];
NSString *path3=[[NSBundlemainBundle]pathForResource:@"DoctorRight"ofType:@"png"];
UIImage *img3=[UIImageimageWithContentsOfFile:path3];
[btn3 setBackgroundImage:img3forState:UIControlStateNormal];
NSString *path3_S=[[NSBundlemainBundle]pathForResource:@"DoctorRight_select"ofType:@"png"];
UIImage *img3_S=[UIImageimageWithContentsOfFile:path3_S];
[btn3 setBackgroundImage:img3_SforState:UIControlStateSelected];
[btn3 addTarget:selfaction:@selector(BtnAuthorityExpertListPress:)forControlEvents:UIControlEventTouchUpInside];
UIView *headview = [[UIViewalloc]initWithFrame:CGRectMake(0, 0, 224, 28)];
[headviewaddSubview:btn1];
[headviewaddSubview:btn2];
[headviewaddSubview:btn3];
self.navigationItem.titleView = headview;
3~导航条设置为不透明
self.navigationController.navigationBar.translucent = NO;//此时页面会自动往下压一个导航条的高度 ,当为YES的时候,为半透明,此时导航条不会占用页面高度