StatusBar status Bar _02

Source: Internet
Author: User

Apple has finally released the iOS 7 release, with a large number of users already upgrading. If the app was generated by Xcode 4.6 or earlier, the IOS 7 system runs the app in compatibility mode to keep it as it should. However, when you recompile your app's source code with Xcode 5, the iOS 7 SDK is used to compile the link. (Note that you back up the project source code before you open the old project using Xcode 5, because Xcode 5 upgrades the resource files in the project and can no longer be opened with the older version of Xcode.) Because the iOS 7 SDK has changed significantly from earlier versions of the SDK, there are also problems with the app's interface, the most obvious of which is the status bar and navigation bar display issues.

IOS6:

iOS7:

When the navigation bar is not being used, the above comparison shows on iOS 6 and iOS 7. The status bar in IOS 6 is opaque, and the view controller's main point of Origin is below the status bar. While the status bar background color of iOS 7 changes to transparent, the view controller's home page origin is in the upper-left corner of the screen, where the status bar appears on the main view and the status bar allows you to display the contents of the views.

IOS 7 provides two status bar styles that control the color of the status bar text.

typedef ns_enum (Nsinteger, Uistatusbarstyle) {Uistatusbarstyledefault=0,//Dark content, for use in light backgroundsUistatusbarstylelightcontent Ns_enum_available_ios (7_0) =1,//Light content, for use on dark backgroundsuistatusbarstyleblacktranslucent Ns_enum_deprecated_ios (2_0, 7_0,"Use uistatusbarstylelightcontent") =1, Uistatusbarstyleblackopaque Ns_enum_deprecated_ios (2_0, 7_0,"Use uistatusbarstylelightcontent") =2,  }; 

If the status bar background is light-colored, use the black typeface (Uistatusbarstyledefault, default), or the white typeface (uistatusbarstylelightcontent) if the background is dark.

Several new methods have been added to the Uiviewcontroller class in IOS 7 to control the status bar.

//These methods control the attributes of the status bar when this view controller is shown.  They can overridden in view controller subclasses to return the desired status bar attributes. -(Uistatusbarstyle) Preferredstatusbarstyle Ns_available_ios (7_0);//Defaults to Uistatusbarstyledefault-(BOOL) Prefersstatusbarhidden Ns_available_ios (7_0);//Defaults to NO//This should is called whenever the return values for the View controller ' s status bar attributes has changed.  If It is a called from within a animation block, the changes would be animated along with the rest of the animation block. - (void) setneedsstatusbarappearanceupdate Ns_available_ios (7_0);

The Preferredstatusbarstyle method specifies the status bar style for the current view controller, and the Prefersstatusbarhidden method specifies whether to hide the status bar. When you modify the font color, display, or hide of the status bar, call the Setneedsstatusbarappearanceupdate method to tell the system that the status bar needs to be refreshed.

Of course, these are the new methods that are added in the iOS 7 SDK. If the app needs to fit the old system (IOS 6 and earlier), you can't use the method above, and you should call the methods provided by the UIApplication class, which is the usual way before iOS 7:

[[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent Animated:YES];  [[UIApplication sharedapplication] Setstatusbarhidden:no Withanimation:uistatusbaranimationfade];

Also set the view controller–based status bar appearance key value in the Info.plist file to No.

StatusBar status Bar _02

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.