Set Status Bar Tint Colour

前端 未结 3 1398
囚心锁ツ
囚心锁ツ 2021-01-23 07:05

I have an tabbed bar application and the status bar tint colour is set to default - so it is always my selected blue colour throughout my app.

However, in one view, I am

3条回答
  •  盖世英雄少女心
    2021-01-23 07:42

    Ahh!!! I have a working solution... albeit a very dirty and makeshift solution.

    1. Simply hide the navigation bar in storyboards (As shown in image in question - uncheck Shows Navigation Bar).
    2. Drag a Navigation Bar into the view.
    3. Set it's Alpha to 0 and uncheck User Interaction Enabled - DO NOT MAKE HIDDEN
    4. Make sure the Navigation Bar is on the top - as shown in following image.

      Screen Capture

    This way your status bar will pick up the correct colour without showing a Navigation Bar.

    Hopefully a more resilient/nicer way to do this will be in a recent Xcode update.

    Top Tip: To make a toolbar look like a navigation bar:

    1. Position the toolbar -1 on the Y axis
    2. Create a label (with no text) with a height of 44px, width 320px and position at 0,0. This will be the bottom border for the tab bar. For best results, take a screenshot of a page of your app and use software to get the colour of the border - this is the darkest part of the tab before the shadow begins (use this colour as the background of the label).

提交回复
热议问题