自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone自動(dòng)隱藏 顯示工具欄和導(dǎo)航條實(shí)例

移動(dòng)開發(fā) iOS
本文介紹的是iPhone自動(dòng)隱藏 顯示工具欄和導(dǎo)航條實(shí)例,很簡(jiǎn)單的一個(gè)小實(shí)例!我們先來看內(nèi)容。

iPhone自動(dòng)隱藏 顯示工具欄導(dǎo)航條實(shí)例是本文要介紹的內(nèi)容,iphone里如何實(shí)現(xiàn)像圖片瀏覽那樣的自動(dòng)隱藏和導(dǎo)航條工具欄呢?其實(shí)很簡(jiǎn)單,只需要設(shè)置toolbar和navigationBar的顯示和隱藏屬性就可以了。效果圖如下:

未隱藏的效果圖

iPhone自動(dòng)隱藏 顯示工具欄和導(dǎo)航條實(shí)例

隱藏后的效果圖

iPhone自動(dòng)隱藏 顯示工具欄和導(dǎo)航條實(shí)例

具體實(shí)現(xiàn)代碼如下

首先在viewDidLoad里設(shè)置toolBarHidden = NO, 默認(rèn)是YES(隱藏的),為了讓toolbar顯示,需要設(shè)置為NO(不隱藏)。

  1. (void)viewDidLoad   
  2. {  
  3.     [super viewDidLoad];  
  4.      self.title = @"隱藏導(dǎo)航欄";  
  5.    // self.toolbarItems  
  6.     selfself.navigationController.toolbar.barStyle = self.toolBar.barStyle;  
  7.     self.navigationController.toolbarHidden = NO;  
  8.       
  9.     [self.navigationController.toolbar setTranslucent:YES];  
  10.       
  11.     self.toolbarItems =  [[[NSMutableArray alloc] initWithArray:self.toolBar.items] autorelease];  

在點(diǎn)擊中間button的時(shí)候的顯示和隱藏navigation bar和toolBar

實(shí)現(xiàn)代碼如下:

  1.  (IBAction)toggleNavigationBar:(id)sender {  
  2.     //Check the current state of the navigation bar...  
  3.     BOOL navBarState = [self.navigationController isNavigationBarHidden];  
  4.     //Set the navigationBarHidden to the opposite of the current state.  
  5.     [self.navigationController setNavigationBarHidden:!navBarState animated:YES];  
  6.     [self.navigationController setToolbarHidden:!navBarState animated:YES];  
  7.     //Change the label on the button.  
  8.     if (navBarState) {  
  9.         [button setTitle:@"隱藏 Navigationr and toolbar" forState:UIControlStateNormal];  
  10.         [button setTitle:@"隱藏 Navigation Bar toolbar" forState:UIControlStateHighlighted];  
  11.     } else {  
  12.         [button setTitle:@"顯示 Navigation Bar toolbar" forState:UIControlStateNormal];  
  13.         [button setTitle:@"顯示  Navigation Bar toolbar" forState:UIControlStateHighlighted];  
  14.     }  

這樣的效果有什么用呢,比如我們常見的電子書,點(diǎn)擊中間那塊區(qū)域的時(shí)候顯示一些設(shè)置和導(dǎo)航。

小結(jié):iPhone自動(dòng)隱藏 顯示工具欄導(dǎo)航條實(shí)例的內(nèi)容介紹完了,希望本文對(duì)你有所幫助!

本文鏈接:http://www.cnblogs.com/likwo/archive/2011/06/12/2078760.htm

責(zé)任編輯:zhaolei 來源: 博客園
相關(guān)推薦

2010-08-25 08:58:32

HTML

2023-09-01 09:47:54

微軟Windows

2009-11-13 10:06:22

Visual Stud

2011-07-21 16:10:48

jQuery Mobi工具欄

2009-07-21 09:06:59

谷歌bing百度

2011-02-22 17:29:24

konqueror

2009-09-22 14:05:46

HTML導(dǎo)航條Visual Stud

2022-02-07 08:01:20

Windows 11平板電腦任務(wù)欄

2021-09-05 06:40:10

微軟Edge瀏覽器

2021-10-10 21:55:04

Windows 11Windows微軟

2012-10-11 11:27:05

火狐開發(fā)工具欄

2011-07-08 14:51:34

iPhone 視圖

2009-08-20 08:56:11

Windows 7QQ故障

2013-04-01 10:01:20

iOS開發(fā)NavigationB

2011-08-18 17:24:34

iPhone開發(fā)UINavigatio

2009-08-25 15:52:27

C#工具欄

2011-09-19 14:15:17

Vista工具欄

2012-06-19 09:31:53

Windows Pho

2009-12-04 16:35:54

Visual Stud

2012-07-18 13:35:58

微軟Office 15
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)