1

How can I constrain the top of my content view to below the status bar? I have tried using SafeArea.Top = StackView.Top (the content showing under the status bar is in a StackView), but the result is as in the image below. (I'm using a Storyboard with Use Safe Area Layout Guides checked)

Content under status bar

Melodius
  • 2,505
  • 3
  • 22
  • 37
  • 2
    Show your storyboard constraint layout. Here is similar reference: [Safe Area of Xcode9](https://stackoverflow.com/questions/44492404/safe-area-of-xcode-9/45334411#45334411) – Krunal Jan 23 '18 at 11:01
  • 2
    do you use storyboards or code? can you show it? – Milan Nosáľ Jan 23 '18 at 11:01
  • Select Your `ViewController` in `StoryBoard` and in Attributes Inspector un-check Under top bar – vp2698 Jan 23 '18 at 11:06
  • Un-checking Under top bar does not affect the outcome. – Melodius Jan 23 '18 at 11:33
  • @Melodius give top constraint constant = 20 – Shezad Jan 23 '18 at 11:55
  • I could do that but then it is not constrained to the bottom of the status bar. What if the user changes ex. accessibility settings to use big fonts? The UI could not adapt to that with a constant of 20. – Melodius Jan 23 '18 at 11:58
  • @Melodius - would you please give more info about the constraints you've already set up? Will be able to help if get some more info. Setting the constant to 20 is a very bad idea - there is no guarantee the status bar to be 20 points - it is bigger on iPhone X and also bigger on non iPhone X devices when there is active call status bar indicator. – plamkata__ Jan 23 '18 at 22:07
  • Thanks plamkata__. It seems that the problem is not the SafeArea constraint. I'm getting a "Unable to satisfy constraints..." complaint that I have to first sort out. I have a bunch of nested UIStackViews that are causing havok. Its a pain to try to find the problem as it has to do with the constraints that the UIStackViews set automatically and that I can't directly check. I'll have to tear down the UI and build it again. I'll get back when I have that sorted. – Melodius Jan 24 '18 at 06:03

1 Answers1

0

For future reference: once I resolved the "Unable to simultaneously satisfy constraints" -problem concerning the UIStackViews that I had embedded in the UIStackView that I was trying to constrain with SafeArea.Top = StackView.Top, the constraint started working as expected.

Melodius
  • 2,505
  • 3
  • 22
  • 37