iOS设置导航按钮
navigationBar中包含了这几个重要组成部分:leftBarButtonItem, rightBarButtonItem, backBarButtonItem, title。
下面是代码
//设置右Btn
UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )]; [rightBtn setTitle:@"搜索" forState:UIControlStateNormal]; [rightBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn]; [self.navigationItem setRightBarButtonItem:rightItem];