日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iphone开发如何隐藏各种bar

發布時間:2023/11/30 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iphone开发如何隐藏各种bar 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉載至:http://blog.csdn.net/riveram/article/details/7291142

狀態條StatusBar

[cpp] view plaincopyprint?
  • [UIApplication?sharedApplication].statusBarHidden?=?YES;??
  • [UIApplication sharedApplication].statusBarHidden = YES;

    ?導航條NavigationBar

    [cpp] view plaincopyprint?
  • [self.navigationController?setNavigationBarHidden:YES];??
  • [self.navigationController setNavigationBarHidden:YES];


    TabBar

    方法1

    [cpp] view plaincopyprint?
  • [self.tabBarController.tabBar?setHidden:YES];??
  • [self.tabBarController.tabBar setHidden:YES];


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

    方法2

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

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

    [cpp] view plaincopyprint?
  • //?The?designated?initializer.??Override?if?you?create?the?controller?programmatically?and?want?to?perform?customization?that?is?not?appropriate?for?viewDidLoad.??
  • ???
  • ?-?(id)initWithNibName:(NSString?*)nibNameOrNil?bundle:(NSBundle?*)nibBundleOrNil?{??
  • ?????self?=?[super?initWithNibName:nibNameOrNil?bundle:nibBundleOrNil];??
  • ?????if?(self)?{??
  • ?????????//?Custom?initialization.??
  • ?????????self.hidesBottomBarWhenPushed?=?YES;??
  • ?????}??
  • ?????return?self;??
  • ?}??
  • // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];if (self) {// Custom initialization.self.hidesBottomBarWhenPushed = YES;}return self;}

    方法3

    [cpp] view plaincopyprint?
  • -?(void)makeTabBarHidden:(BOOL)hide??
  • ?{??
  • ?????if?(?[self.tabBarController.view.subviews?count]?<?2?)??
  • ?????{??
  • ?????????return;??
  • ?????}??
  • ?????UIView?*contentView;??
  • ??????
  • ?????if?(?[[self.tabBarController.view.subviews?objectAtIndex:0]?isKindOfClass:[UITabBar?class]]?)??
  • ?????{??
  • ?????????contentView?=?[self.tabBarController.view.subviews?objectAtIndex:1];??
  • ?????}??
  • ?????else??
  • ?????{??
  • ?????????contentView?=?[self.tabBarController.view.subviews?objectAtIndex:0];??
  • ?????}??
  • ?????//????[UIView?beginAnimations:@"TabbarHide"?context:nil];??
  • ?????if?(?hide?)??
  • ?????{??
  • ?????????contentView.frame?=?self.tabBarController.view.bounds;??????????
  • ?????}??
  • ?????else??
  • ?????{??
  • ?????????contentView.frame?=?CGRectMake(self.tabBarController.view.bounds.origin.x,??
  • ????????????????????????????????????????self.tabBarController.view.bounds.origin.y,??
  • ????????????????????????????????????????self.tabBarController.view.bounds.size.width,??
  • ????????????????????????????????????????self.tabBarController.view.bounds.size.height?-?self.tabBarController.tabBar.frame.size.height);??
  • ?????}??
  • ??????
  • ?????self.tabBarController.tabBar.hidden?=?hide;??
  • ?????//????[UIView?commitAnimations];?????
  • ?}??
  • - (void)makeTabBarHidden:(BOOL)hide{if ( [self.tabBarController.view.subviews count] < 2 ){return;}UIView *contentView;if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] ){contentView = [self.tabBarController.view.subviews objectAtIndex:1];}else{contentView = [self.tabBarController.view.subviews objectAtIndex:0];}// [UIView beginAnimations:@"TabbarHide" context:nil];if ( hide ){contentView.frame = self.tabBarController.view.bounds; }else{contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x,self.tabBarController.view.bounds.origin.y,self.tabBarController.view.bounds.size.width,self.tabBarController.view.bounds.size.height - self.tabBarController.tabBar.frame.size.height);}self.tabBarController.tabBar.hidden = hide;// [UIView commitAnimations]; }



    時機

    [cpp] view plaincopyprint?
  • -?(void)viewWillAppear:(BOOL)animated?{??
  • ?????[self?setFullScreen:YES];??
  • ?}??
  • ???
  • ?-?(void)viewWillDisappear:(BOOL)animated?{??
  • ?????[self?setFullScreen:NO];??
  • ?}??
  • ???
  • ?-?(void)setFullScreen:(BOOL)fullScreen?{??
  • ?????//?狀態條 ??
  • ?????[UIApplication?sharedApplication].statusBarHidden?=?fullScreen;??
  • ?????//?導航條 ??
  • ?????[self.navigationController?setNavigationBarHidden:fullScreen];??
  • ?????//?tabBar的隱藏通過在初始化方法中設置hidesBottomBarWhenPushed屬性來實現。??
  • ?}??
  • - (void)viewWillAppear:(BOOL)animated {[self setFullScreen:YES];}- (void)viewWillDisappear:(BOOL)animated {[self setFullScreen:NO];}- (void)setFullScreen:(BOOL)fullScreen {// 狀態條[UIApplication sharedApplication].statusBarHidden = fullScreen;// 導航條[self.navigationController setNavigationBarHidden:fullScreen];// tabBar的隱藏通過在初始化方法中設置hidesBottomBarWhenPushed屬性來實現。}


    總結

    以上是生活随笔為你收集整理的iphone开发如何隐藏各种bar的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。