首页 > 代码库 > navigationitem的背景图片和左边返回按钮 以及文字

navigationitem的背景图片和左边返回按钮 以及文字



[self.navigationController.navigationBar setBackgroundImage:imag forBarMetrics:UIBarMetricsDefault];


//button 定义你要的背景 文字 或 事件

 UIBarButtonItem *leftBarButton = [[UIBarButtonItem allocinitWithCustomView:button];

 self.navigationItem.leftBarButtonItem = leftBarButton;

 [leftBarButton release];



具体实现:

[self.navigationItemsetTitle:@"通知详情"];

    //self.navigationController.navigationBarHidden = NO;

    [self.navigationController.navigationBarsetBackgroundImage:[UIImage imageNamed:@"root_top.png"]forBarMetrics:UIBarMetricsDefault];

    self.navigationItem.hidesBackButton =YES;

    

    UIButton *rightButton = [[UIButtonalloc]initWithFrame:CGRectMake(SCREEN_WIDTH -70, 10,70, rootTopHeight -20)];

    [rightButton addTarget:selfaction:@selector(NoticeBackAction)forControlEvents:UIControlEventTouchUpInside];

    [rightButton setBackgroundImage:[UIImageimageNamed:@"root_back.png"]forState:UIControlStateNormal];

    [rightButton setTitle:@"退出"forState:UIControlStateNormal];

    UIBarButtonItem *rightBarButton = [[UIBarButtonItemalloc]initWithCustomView:rightButton];

    self.navigationItem.rightBarButtonItem = rightBarButton;


navigationitem的背景图片和左边返回按钮 以及文字