操纵状态栏-iOS开发


状态栏是可以通过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;  

相关内容