ios中导航控制器的使用

2023-05-16

在window中设置导航控制器

FirstViewController *first=[FirstViewController alloc];
//创建导航控制器
UINavigationController *controller=[[UINavigationController alloc]initWithRootViewController:first];
//将导航控制器作为window的根视图
self.window.rootViewController=controller;
//设置导航栏的颜色
controller.navigationBar.barTintColor=[UIColor greenColor];

设置页面导航控制器的内容

//设置导航栏中间内容
self.navigationItem.title=@"首页";
//设置导航栏右侧按钮
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"右侧" style:UIBarButtonItemStylePlain target:self action:@selector(touchRight)];

设置导航控制器的按钮点击事件

-(void)touchRight{
    SecondViewController *second=[[SecondViewController alloc]init];
    [self.navigationController pushViewController:second animated:YES];
    [self.navigationController popViewControllerAnimated:YES];

}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ios中导航控制器的使用 的相关文章

随机推荐