iphone開發如何隱藏各種bar

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

狀態條StatusBar

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

?導航條NavigationBar

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


TabBar

方法1

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


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

方法2

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

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

[cpp] view plaincopyprint?
  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. ?}??
// 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?
  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. ?}??
- (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?
  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. ?}??
- (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屬性來實現。
}


本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/388358.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388358.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388358.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Swift5.1 語言指南(九) 閉包

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★?微信公眾號&#xff1a;山青詠芝&#xff08;shanqingyongzhi&#xff09;?博客園地址&#xff1a;山青詠芝&#xff08;https://www.cnblogs.com/strengthen/&#xff09;?GitHub地址&a…

服務器被攻擊怎么修改,服務器一直被攻擊怎么辦?

原標題&#xff1a;服務器一直被攻擊怎么辦&#xff1f;有很多人問說&#xff0c;網站一直被攻擊&#xff0c;什么被掛馬&#xff0c;什么被黑&#xff0c;每天一早打開網站&#xff0c;總是會出現各種各樣的問題&#xff0c;這著實讓站長們揪心。從修改服務器管理賬號開始&…

腳本 api_從腳本到預測API

腳本 apiThis is the continuation of my previous article:這是我上一篇文章的延續&#xff1a; From Jupyter Notebook To Scripts從Jupyter Notebook到腳本 Last time we discussed how to convert Jupyter Notebook to scripts, together with all sorts of basic engine…

Iphone代碼創建視圖

要想以編程的方式創建視圖&#xff0c;需要使用視圖控制器中定義的viewDidLoad方法&#xff0c;只有在運行期間生成UI時才需要實現該方法。 在此只貼出viewDidLoad方法的代碼&#xff0c;因為只需要在這個方法里面編寫代碼&#xff1a; [cpp] view plaincopyprint?- (void)vi…

聊聊flink Table的OrderBy及Limit

序 本文主要研究一下flink Table的OrderBy及Limit 實例 Table in tableEnv.fromDataSet(ds, "a, b, c"); Table result in.orderBy("a.asc");Table in tableEnv.fromDataSet(ds, "a, b, c");// returns the first 5 records from the sorted …

binary masks_Python中的Masks概念

binary masksAll men are sculptors, constantly chipping away the unwanted parts of their lives, trying to create their idea of a masterpiece … Eddie Murphy所有的人都是雕塑家&#xff0c;不斷地消除生活中不必要的部分&#xff0c;試圖建立自己的杰作理念……埃迪墨…

css+沿正方形旋轉,CSS3+SVG+JS 正方形沿著正方本中軸移動翻轉的動畫

CSS語言&#xff1a;CSSSCSS確定* {margin: 0;padding: 0;fill: currentColor;vector-effect: non-scaling-stroke;}html {overflow: hidden;}body {display: flex;flex-direction: column;margin: 0;min-width: 10em;height: 100vh;}body > svg,body > input,body > …

Iphone在ScrollView下點擊TextField使文本筐不被鍵盤遮住

1.拖一個Scroll View視圖填充View窗口&#xff0c;將Scroll View視圖拖大一些&#xff0c;使其超出屏幕。 2.向Scroll View拖&#xff08;添加&#xff09;多個Label視圖和Text View視圖。 3.在.h頭文件中添加如下代碼&#xff1a; [cpp] view plaincopyprint?#import <U…

兩高發布司法解釋 依法嚴懲涉地下錢莊犯罪

新華社北京1月31日電&#xff08;記者丁小溪&#xff09;最高人民法院、最高人民檢察院31日聯合發布關于辦理非法從事資金支付結算業務、非法買賣外匯刑事案件適用法律若干問題的解釋&#xff0c;旨在依法懲治非法從事資金支付結算業務、非法買賣外匯犯罪活動&#xff0c;維護金…

python 儀表盤_如何使用Python刮除儀表板

python 儀表盤Dashboard scraping is a useful skill to have when the only way to interact with the data you need is through a dashboard. We’re going to learn how to scrape data from a dashboard using the Selenium and Beautiful Soup packages in Python. The S…

VS2015 定時服務及控制端

一. 服務端 如下圖—新建項目—經典桌面—Windows服務—起名svrr2. 打到server1 改名為svrExecSqlInsert 右擊對應的設計界面&#xff0c;添加安裝服務目錄結構如圖 3. svrExecSqlInsert里有打到OnStart()方法開始寫代碼如下 /// <summary>/// 服務開啟操作/// </su…

css文件如何設置scss,Webpack - 如何將scss編譯成單獨的css文件?

2 個答案:答案 0 :(得分&#xff1a;3)這是我在嘗試將css編譯成單獨文件時使用的webpack.config.js文件|-- App|-- dist|-- src|-- css|-- header.css|-- sass|-- img|-- partials|-- _variables.scss|-- main.scss|--ts|-- tsconfig.json|-- user.ts|-- main.js|-- app.js|-- …

Iphone表視圖的簡單操作

1.創建一個Navigation—based—Application項目&#xff0c;這樣Interface Builder中會自動生成一個Table View&#xff0c;然后將Search Bar拖放到表示圖上&#xff0c;以我們要給表示圖添加搜索功能&#xff0c;不要忘記將Search Bar的delegate連接到File‘s Owner項&#xf…

PhantomJS的使用

PhantomJS安裝下載地址 配置環境變量 成功&#xff01; 轉載于:https://www.cnblogs.com/hankleo/p/9736323.html

aws emr 大數據分析_DataOps —使用AWS Lambda和Amazon EMR的全自動,低成本數據管道

aws emr 大數據分析Progression is continuous. Taking a flashback journey through my 25 years career in information technology, I have experienced several phases of progression and adaptation.進步是連續的。 在我25年的信息技術職業生涯中經歷了一次閃回之旅&…

21eval 函數

eval() 函數十分強大 ---- 將字符串 當成 有效的表達式 來求職 并 返回計算結果 1 # 基本的數學計算2 print(eval("1 1")) # 23 4 # 字符串重復5 print(eval("* * 5")) # *****6 7 # 將字符串轉換成列表8 print(eval("[1, 2, 3, 4]")) # [1,…

聯想r630服務器開啟虛擬化,整合虛擬化 聯想萬全R630服務器上市

虛擬化技術的突飛猛進&#xff0c;對運行虛擬化應用的服務器平臺的運算性能提出了更高的要求。近日&#xff0c;聯想萬全R630G7正式對外發布。這款計算性能強勁&#xff0c;IO吞吐能力強大的四路四核服務器&#xff0c;主要面向高端企業級應用而開發。不僅能夠完美承載大規模數…

Iphone屏幕旋轉

該示例是想在手機屏幕方向發生改變時重新定位視圖&#xff08;這里是一個button&#xff09; 1.創建一個View—based Application項目,并在View窗口中添加一個Round Rect Button視圖&#xff0c;通過尺寸檢查器設置其位置&#xff0c;然后單擊View窗口右上角的箭頭圖標來旋轉窗…

先進的NumPy數據科學

We will be covering some of the advanced concepts of NumPy specifically functions and methods required to work on a realtime dataset. Concepts covered here are more than enough to start your journey with data.我們將介紹NumPy的一些高級概念&#xff0c;特別是…

lsof命令詳解

基礎命令學習目錄首頁 原文鏈接&#xff1a;https://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316599.html 簡介 lsof(list open files)是一個列出當前系統打開文件的工具。在linux環境下&#xff0c;任何事物都以文件的形式存在&#xff0c;通過文件不僅僅可以訪問常規…