iOS Some pages in can also be embedded WebView, then WebView of use H5 Made a navigation , and iOS The color of the status bar is difficult to adjust H5 The color of the navigation is the same . As shown in the figure below :

In fact, this kind of reason , Mainly because of the use of 16 Binary color , Causes color conversion to deviate .

I'm here because H5 What is the color in the picture #3983E5, Instead, it uses the following method to transform UIColor Error :

+ (UIColor *) colorWithHexString: (NSString *)color
    NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    // String should be 6 or 8 characters
    if ([cString length] < 6) {
        return [UIColor clearColor];
    // strip 0X if it appears
    if ([cString hasPrefix:@"0X"])
        cString = [cString substringFromIndex:2];
    if ([cString hasPrefix:@"#"])
        cString = [cString substringFromIndex:1];
    if ([cString length] != 6)
        return [UIColor clearColor];
    // Separate into r, g, b substrings
    NSRange range;
    range.location = 0;
    range.length = 2;
    NSString *rString = [cString substringWithRange:range];
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    // Scan values
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:1.0f];

You can check it , In your project H5 Is it also used in the classroom 16 Binary color .

And then I made a custom one 16 Color conversion to UIColor Methods .

Want to make the navigation bar color and status bar color exactly the same , So just another way .

Use RGBA Color representation is enough .RGBA , respectively, It's red 、 green 、 Blue 、 transparency .

such as , I'm here H5 Change the color of the navigation bar to (1,159,239,1), And then in the project, you just need to put self.view The background color of [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a], Just show it .

About this API, Generally, a short macro is defined .

#define RGB(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

I set it like this here self.view Background color of :

self.view.backgroundColor = RGB(1,159,239,1);

The colors of the navigation bar and the status bar are exactly the same .

iOS Make the color of the status bar match H5 In the background color consistent more related articles

  1. stay iOS Next -input[disabled] Lighten the color &amp;&amp; input[readonly] Focus solutions are still available

    The goal is : Writing input Input box time , Want to make it read-only and not write . Environmental Science : stay iPhone On When it was used readonly, But readonly, You can actually get the focus , Can't pop up the keyboard : There's nothing wrong with Android phones , So I used it disable ...

  2. iOS Set the color of the status bar

    The font of the status bar is black :UIStatusBarStyleDefault The font of the status bar is white :UIStatusBarStyleLightContent One . stay info.plist in , take View contro ...

  3. iOS change App The color of the status bar is white

    The default status bar is black , For certain App Not very beautiful , It's easy to turn white , There are only two steps . 1. stay Info.plist Add new items to ,View controller-based status bar appearan ...

  4. iOS Change the color of the status bar

    1. Find... In the project info.plist   file , Click on “+” Number , choice View controller-based status bar appearance And set it as  NO 2. stay  AppDelegate ...

  5. ios How to make the color of the status bar the same as the background image of the navigation bar

    ios7  Picture as the background of navigation , If you want to realize the integration of status bar and navigation bar , So the image height needs to be increased 22, That is to say 64,retina yes 128

  6. ios Next app Embedded h5 Page is video Adaptation problem

    ios Let's do the news details h5 The page is implemented and packaged into app in , There will be videos on the news details page , Android II video Of poster You can adapt video size , however ios I'll follow poster The image size will be video It's bigger than that , But as ...

  7. iOS How to make the status bar with the search bar below or NavigationBar or toolBar The color is the same

    stay iOS7 after ,status bar It's transparent (transparent),navigation bars,tab bars,toolbars,search bars and scope bars It's translucent ...

  8. JS Judgment is IOS still Android And how to solve it h5 After packing, it's in ios Next, the content overlaps with the status bar

    h5 After packing, it's in ios Next, the content overlaps with the status bar : 1: Know the type of device : var u = navigator.userAgent, app = navigator.appVersion; var isAndr ...

  9. iosselect: One js picker project , stay H5 To realize IOS Of select Drop down box effect

    Specific documents and demo You can visit github: Mobile browser for select It's inconsistent with the presentation style of ,ios The next one is similar to the original one pi ...

Random recommendation

  1. Magical Platform class library code sharing

    I have nothing to do these days , Just sort out some class libraries .jQuery Plug ins and custom controls . Today I'd like to share with you Magical Platform class library code . The figure below shows the whole solution .MagicalPlatForm It defines a lot of Layer layer :Mag ...

  2. ES6 New characteristics :Javascript Delay objects built into Promise

    Promise Basic use of : utilize Promise Is the solution JS The problem of nested callback function in asynchronous execution , More concise control function execution process : adopt new Instantiation Promise,   The constructor takes two arguments , The first parameter is the function ...

  3. 【 abnormal 】ORA-01536: space quota exceeded for tablespace

    ### The error may exist in /src/main/resources/com/star/css/dao/sql/workflow.xml ### The error may i ...

  4. About SharePoint 2013 UserProfile A few notes on cross field

    1. The following are required in cross field Service example , None of these will have all kinds of problems 2. Publishing field and consumption field need to be created at the same time Host Site , Otherwise, the consumer market is SiteFeed Can't use . 3. Please refer to :http://www. ...

  5. ios git Terminal submission

    git status    // Check submission status git status On branch master  // Check the branch git branch   // View branches git add *   // Add all local more ...

  6. Android Network communication library Volley brief introduction

    1. What is? Volley before this , When we need to communicate with the network in the program , There is nothing in general use more than AsyncTaskLoader,HttpURLConnection,AsyncTask,HTTPClient( ...

  7. FIREDAC Direct connection ORACLE database

    UniDac Yes Oracle Of Direct Connect , You don't need a condom Oracle client dll,deploy Time really time Convenient and fast .FireDac Connect Oracle, In the absence of Oracle Client Under the circumstances , It can be connected to ...

  8. mysql Summary of stored procedure project

    1. false :0  true 1 Bear in mind Official documents : BOOL,  ...

  9. Android Application development learning Toast Message box

    author : Liu Haoyu Blog : Let's look at Toast The usage of message prompt box . Use Toast There are three steps to a message prompt box : 1.  Create a Toast object . can ...

  10. Codeforces Round #523 (Div. 2) D. TV Shows simulation ( Multiple sets Let's add all the intervals to the multiple set first )+ greedy + Two points

    The question : give n The start and end time of a TV program   And renting a TV requires x +y*(b-a)  [a,b] For the time period What's the minimum cost of watching a TV program Ideas : Greedy thoughts situation 1 If the cost of renting a new TV <= In the air ...