iOS9如何隱藏各種bar

來源:互聯網
上載者:User

標籤:

轉載自:http://www.cnblogs.com/aBigRoybot/articles/2234487.html狀態條StatusBar
1     [UIApplication sharedApplication].statusBarHidden = YES;
導航條NavigationBar
1     [self.navigationController setNavigationBarHidden:YES];
TabBar方法1
1     [self.tabBarController.tabBar setHidden:YES];

這個方法有問題,雖然tabBar被隱藏了,但是那片地區變成了一片空白,無法被其他視圖使用。

方法2

對於navigationController+tabBarController的結構,可以在push下一級的childController之前將childController的hidesBottomBarWhenPushed屬性設為YES。

比如,可以在childController的初始化方法中做這件事,代碼如下:

 1 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
2
3 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
4 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
5 if (self) {
6 // Custom initialization.
7 self.hidesBottomBarWhenPushed = YES;
8 }
9 return self;
10 }
方法3

http://www.azumi.cc/thread-539502-1-1.html

 1 - (void)makeTabBarHidden:(BOOL)hide
2 {
3 if ( [self.tabBarController.view.subviews count] < 2 )
4 {
5 return;
6 }
7 UIView *contentView;
8
9 if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
10 {
11 contentView = [self.tabBarController.view.subviews objectAtIndex:1];
12 }
13 else
14 {
15 contentView = [self.tabBarController.view.subviews objectAtIndex:0];
16 }
17 // [UIView beginAnimations:@"TabbarHide" context:nil];
18 if ( hide )
19 {
20 contentView.frame = self.tabBarController.view.bounds;
21 }
22 else
23 {
24 contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x,
25 self.tabBarController.view.bounds.origin.y,
26 self.tabBarController.view.bounds.size.width,
27 self.tabBarController.view.bounds.size.height - self.tabBarController.tabBar.frame.size.height);
28 }
29
30 self.tabBarController.tabBar.hidden = hide;
31 // [UIView commitAnimations];
32 }
時機
 1 - (void)viewWillAppear:(BOOL)animated {
2 [self setFullScreen:YES];
3 }
4
5 - (void)viewWillDisappear:(BOOL)animated {
6 [self setFullScreen:NO];
7 }
8
9 - (void)setFullScreen:(BOOL)fullScreen {
10 // 狀態條
11 [UIApplication sharedApplication].statusBarHidden = fullScreen;
12 // 導航條
13 [self.navigationController setNavigationBarHidden:fullScreen];
14 // tabBar的隱藏通過在初始化方法中設定hidesBottomBarWhenPushed屬性來實現。
15 }

iOS9如何隱藏各種bar

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.