UINavigationBar *navBar =
[[UINavigationBaralloc]
initWithFrame:CGRectMake(0, 0, 824, 44)];
navBar.barStyle = UIBarStyleDefault;
UINavigationItem
*navItem = [[UINavigationItemalloc]
init];
navItem.leftItemsSupplementBackButton = YES;
navItem.title = @"Add
CRA";
UIBarButtonItem
*leftButton = [[UIBarButtonItemalloc]
initWithTitle:@"Back"
style:UIBarButtonItemStylePlain
target:self
action:@selector(back)];
navItem.leftBarButtonItem =
leftButton;
UIBarButtonItem
*rightButton = [[UIBarButtonItemalloc]
initWithTitle:@"Done"
style:UIBarButtonItemStylePlain
target:self
action:@selector(done)];
navItem.rightBarButtonItem =
rightButton;
navBar.items = @[navItem];
[self.view addSubview:navBar];
添加navbar以及上面的左右按钮代码,码迷,mamicode.com
时间: 2024-11-08 21:33:52