歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 操縱狀態欄-iOS開發

操縱狀態欄-iOS開發

日期:2017/3/1 10:28:34   编辑:Linux編程

狀態欄是可以通過UIApplication類提供的一些方法來修改的,比如完全去掉狀態欄或者修改風格,不過這些改變只是在你的程序內部,當你退出你的程序又會復原。

  1. UIApplication *myApp = [UIapplication sharedApplication];

1.隱藏狀態欄

  1. [myApp setStatusBarHidden:YES animated:YES];

記得隱藏狀態欄後的你的“桌面”就增加320×20的大小,所以最好是在任何window或者view創建之前隱藏它。

2.狀態欄風格

  1. [myApp setStatusBarStyle: UIStatusbarStyleBlackOpaque];

  1. typedef enum {
  2. UIStatusBarStyleDefault,
  3. UIStatusBarStyleBlackTranslucent,
  4. UIStatusBarStyleBlackOpaque
  5. } UIStatusBarStyle;

3.狀態欄方向

  1. [myApp setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
  1. typedef enum {
  2. UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
  3. //豎屏,垂直向上
  4. UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
  5. //豎屏,垂直方向上下顛倒
  6. UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
  7. //設備逆時針旋轉到橫屏模式
  8. UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
  9. //設備順時針旋轉到橫屏模式
  10. } UIInterfaceOrientation;
Copyright © Linux教程網 All Rights Reserved