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