navigationController背景图,文字,事件定义

//设置背景图片

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

 

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

 

 UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:button];

 self.navigationItem.leftBarButtonItem = leftBarButton;

 [leftBarButton release];

 

 

具体实现:

 

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

    //self.navigationController.navigationBarHidden = NO;

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

    self.navigationItem.hidesBackButton = YES;

    

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

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

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

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

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

    self.navigationItem.rightBarButtonItem = rightBarButton;

posted @ 2015-10-25 16:47  littlewrong  阅读(238)  评论(0)    收藏  举报