Sagit.Framework For IOS automatic layout tutorial: 5. Status bar: height, style foreground control, status bar uiview control, hidden control

Time:2020-10-28

preface:

The interface of IOS is divided into status bar, navigation bar, main interface and bottom status bar.

This article describes the operation of the status bar.

1: Height of status bar:

The framework is automatic layout and adaptive, so a macro definition is provided to represent the height of the status bar

 

When the page layout needs to use the height of the status bar, use ststatushightpx.

When there is no navigation bar on the page, the main uiview is displayed on the full screen. In this case, the height of the status bar may be used in the layout and calculation of relative position.

2. Style text color style control of status bar

Method definition:

 

//! set the display style of view status bar: default Global
-(UIViewController*)setStatusBarStyle:(UIStatusBarStyle)style;
//! set the display style of current view status bar: default global @ forthisview is invalid only in current view default: no
-(UIViewController*)setStatusBarStyle:(UIStatusBarStyle)style forThisView:(BOOL)forThisView;

 

A. Font color type [black white]:

-(void)onInit
{
    //Status bar
    [self setStatu sBarStyle:UIStatusBarStyleLightContent ]; // start, the color of Chinese characters is black, and the color is changed to white and takes effect globally
}

This is the global setting.

Local settings:

-(void)onInit
{
    //Status bar
    [self setStatu sBarStyle:UIStatusBarStyleLightContent forThisView : Yes]; // start, the color of Chinese characters is black, and it is changed to white and takes effect globally
}

 

B. Control background to color or image: (SAGIT= self.view )

    [self.view.statusBar backgroundImage:@"circle_bg"];
    [[sagit statusBar] backgroundColor:ColorBlue];

You can get the UI form of the status bar in any view, get a uiview, and then set the background color or background image.

The settings here also take effect globally.

3. Hide or show the status bar (self is the current controller)

- (void)initUI
{
    [self needStatusBar:NO];
}

The parameters yes and no control whether it is displayed or hidden.

The default global definition is display, so as long as the hidden page is set, the displayed page does not need to be set.

other:

Various status bar and hidden bar bugs or small problems, the framework has been dealt with internally.