IOS中自定义导航栏标题

来源:互联网 发布:游戏无线鼠标推荐 知乎 编辑:程序博客网 时间:2024/04/30 02:07

IOS中自定义导航栏标题:



 UILabel *titleText = [[UILabel allocinitWithFrameCGRectMake(160012050)];

 titleText.backgroundColor = [UIColor clearColor];

 titleText.textColor=[UIColor whiteColor];

 [titleText setFont:[UIFont systemFontOfSize:17.0]];

 [titleText setText:@"XXX"];

 self.navigationItem.titleView=titleText;

 [titleText release];



IOS中自定义导航栏返回按钮:(放在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];

 


IOS中自定义导航栏右边按钮



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];

0 0