IOS - How to revert top 20px in storyboard with translucent black status bar

I have a problem with the top 20px behind the status bar, in particular I can't put anything there.

When I created the UI, I took a storyboard approach and set the status bar style to semi-transparent black. But when in Xcode layout my view's height is fixed at 460px (greyed out).

Please, help.


Got a response from a friend, will mark his solution as correct as soon as he posts it here. So far, here's the solution:

+3


source to share


4 answers


Here's a solution without a separate line of code.

  • In frontend, Builder configured the view controller as required full screen and freeform size.
  • In the view size settings, set the height to 480px
  • Make sure the status bar style is semi-transparent in Info.plist.
  • Run and observe


See links to screenshots of each step in the top post.

+7


source


Okay, when I was told it was possible, I tried to place the view on top of the main view and set its y coordinate to -20. Then west to Info.plist and set Status bar style

to Transparent black style (alpha of 0.5)

. The view I posted was visible under the status bar.

enter image description here

This only happened at runtime; in the Buider interface, the simulated semi-transparent status bar is gray but opaque.

Edit . If you want to move the main view of the view mode controller to this space, it is possible in time viewWillAppear

. (If you try to move it in time viewDidLoad

, it will be moved back.)

- (void)viewWillAppear:(BOOL)animated;
{
    [super viewWillAppear:animated];

    // Move the main view upwards if it isn't already there.
    CGRect frame = [[self view] frame];
    frame.size.height += frame.origin.y;
    frame.origin.y = 0;
    [[self view] setFrame:frame];
}

      



However, it comes back after the rotation and my attempts to respond to the rotation ended up breaking the cell layout if I did it with UITableView

.

Here is the Swift version. Seems to work. Good solution for taking screenshots in App Store (in addition to changing info.plist settings.

override func viewWillAppear (animated: Bool) {

    super.viewWillAppear(animated)

    // Move the main view upwards if it isn't already there.
    var frame: CGRect = self.view.frame
    frame.size.height += frame.origin.y
    frame.origin.y = 0
    self.view.frame = frame
}

      

+2


source


Just create a negative Y coordinate (-20) in the interface builder.

+1


source


Try changing the value for Status Bar in the Simulated Metrics section of the Attribute inspector in Interface Builder. If you set it to "Inferred", Xcode will not make any assumptions about the view controller, letting you set the size of the view to ANY size you want (even sizes that don't make any sense). Check out this post about the status bar for information on hiding it in your application.

-1


source







All Articles