操纵状态栏-IOS开发

来源:互联网 发布:java xml与java关联 编辑:程序博客网 时间:2024/04/28 14:59

状态栏是可以通过UIApplication类提供的一些方法来修改的,比如完全去掉状态栏或者修改风格,不过这些改变只是在你的程序内部,当你退出你的程序又会复原。

UIApplication *myApp = [UIapplication sharedApplication];

1.隐藏状态栏

[myApp setStatusBarHidden:YES animated:YES];

记得隐藏状态栏后的你的“桌面”就增加320×20的大小,所以最好是在任何window或者view创建之前隐藏它。

2.状态栏风格

[myApp setStatusBarStyle: UIStatusbarStyleBlackOpaque];

typedef enum {        UIStatusBarStyleDefault,        UIStatusBarStyleBlackTranslucent,        UIStatusBarStyleBlackOpaque    } UIStatusBarStyle;

3.状态栏方向

[myApp setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];

 typedef enum {      UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,      //竖屏,垂直向上      UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,      //竖屏,垂直方向上下颠倒      UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,      //设备逆时针旋转到横屏模式      UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft      //设备顺时针旋转到横屏模式    } UIInterfaceOrientation;