本文主要是介绍UINavigationController 导航控制器 IOS7适配 导航栏不透明,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
摘要 UINavigationController 导航控制器 IOS7适配 导航栏不透明 UINavigationController 导航控制器 IOS7适配 导航栏不透明
导航控制器使用了导航堆栈。根视图控制器(Settings)在堆栈最底层,以此类推。可以理解为一本书,一页一页的。这样就控制了 试图控制器
?
1 2 3 | self.title = @ "Settings" ; 这是一个View 那就好办了,我们可以添加button imageView UISegmentedControl选项卡 |
?
1 2 3 4 5 | ViewController1* vc = [[ViewController1 alloc] init]; UINavigationController* nc = [[UINavigationController alloc] initWithRootViewController:vc]; self.window.rootViewController = nc; |
?
1 2 3 4 5 6 7 8 9 | ViewController2* vc2 = [[ViewController2 alloc] init]; [self.navigationController pushViewController:vc2 animated:YES]; [self.navigationController popViewControllerAnimated:YES]; [self.navigationController popToRootViewControllerAnimated:YES]; [self.navigationController popToViewController:vcX animated:YES]; |
bar:
包含左右UIBarButtonItem,也就是左右两个按钮,下面添加左面按钮:
?
1 2 3 | UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(clickLeftButton)]; self.navigationItem.leftBarButtonItem = leftButton; |
当然左边的默认显示的。右面的就不在这里添加了吧
下面是按钮样式,自行参考
toolBar:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | [self.navigationController setToolbarHidden:NO]; [self setToolbarItems:[NSArray arrayWithObjects:,,,, nil]; 初始化 用setItems 添加 UIBarButtonItem UIToolbar* toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 416-84, 320, 44)]; toolBar.hidden = YES; [self.view addSubview:toolBar]; NSMutableArray* array = [NSMutableArray array ]; for (int i = 0; i < 7; i++) { if (i%2==0) { UIBarButtonItem* button = [[[UIBarButtonItem alloc] initWithTitle:[NSString stringWithFormat:@ "%d" ,i] style:UIBarButtonItemStyleBordered target:self action:nil] autorelease]; [ array addObject:button]; } else { UIBarButtonItem* button = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil] autorelease]; [ array addObject:button]; } } [toolBar setItems: array animated:YES]; [self setToolbarItems: array ]; |
自定义按钮
?
1 2 | barButton = [[UIBarButtonItem alloc] initWithCustomView:mybutton]; |
// 让iOS7 导航控制器不透明
?
1 2 | self.navigationController.navigationBar.translucent = NO; self.edgesForExtendedLayout = UIRectEdgeNone; |
//隐藏导航栏
?
1 | [[self navigationController] setNavigationBarHidden:YES animated:YES]; |
这篇关于UINavigationController 导航控制器 IOS7适配 导航栏不透明的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!