Just My Life & My Work

既然能夠改變狀態列文字的顏色,那如果我覺得它太醜⋯⋯而想隱藏狀態列的話該怎麼做?

status bar show

在地圖上的狀態列是有愛眼呢~

雖然程式碼很簡單,然而iOS 6iOS 7有不同的寫法⋯⋯


/**
 Theme: Hide & Show Status Bar
 IDE: Xcode 5
 Language: Objective C
 Date: 103/03/24
 Author: HappyMan
 Blog: https://cg2010studio.wordpress.com/
 */
// iOS 7
-(BOOL)prefersStatusBarHidden
{
    return YES;
}
// iOS 6
// 設定 Status Bar 是否隱藏,包含漸入漸岀特效
[[UIApplication sharedApplication]
 setStatusBarHidden:true
 withAnimation:UIStatusBarAnimationFade];
// 設定 Status Bar 是否隱藏,包含滑入滑出特效
[[UIApplication sharedApplication]
 setStatusBarHidden:true
 withAnimation:UIStatusBarAnimationSlide];

iOS6什麼地方都可以設定,iOS7則需複寫方法。

status bar hide

狀態列隱藏較為清爽~

2016/11/19更新:

若一開始要隱藏狀態列,在info.plist可以這麼設定就好:

  • View controller-based status bar appearance (Boolean: NO)
  • Status bar is initially hidden (Boolean: YES)

參考:Cant hide iOS 7 status barStatus Bar 隱藏/顯示【ios】status bar hiddenHide the status bar in ios 9

隨意留個言吧:)~

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料

標籤雲