1、导航栏标题:
(1)自定义标题
UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(160, 0, 120, 50)];
titleText.backgroundColor = [UIColor clearColor];
titleText.textColor=[UIColor whiteColor];
[titleText setFont:[UIFont systemFontOfSize:17.0]];
[titleText setText:@"XXX"];
self.navigationItem.titleView=titleText;
[titleText release];
(2)titleView
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"title_logo"]];
(3)改UINavagation的tietle的颜色
collectNav.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
2、自定义导航栏返回按钮:(放在pushViewController之前)
UIBarButtonItem *backItem=[[UIBarButtonItem alloc]init];
backItem.title=@"后退";
backItem.tintColor=[UIColor colorWithRed:129/255.0 green:129/255.0 blue:129/255.0 alpha:1.0];
self.navigationItem.backBarButtonItem = backItem;
[backItem release];
3、自定义导航栏右边按钮
UIBarButtonItem * rightButton = [[UIBarButtonItem alloc]
initWithTitle:@"回到首页"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(callModalList)];
rightButton.image=[UIImage imageNamed:@"right_button.png"];
rightButton.tintColor=[UIColor colorWithRed:74/255.0 green:74/255.0 blue:74/255.0 alpha:1.0];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];
4、给UINavagation加背景图
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"home_bottom_mask"] forBarMetrics:UIBarMetricsDefault];