0

I just realise that my app is not working for iphoneX's design. I have a UIVIew (containing textfield and button) tends to be like navigation bar so it does support for iPhone 8 and 8 plus. However, the iPhoneX has blank white for the top section. Vice versa, if I set the Uiview to act like navigation bar, then the iphone8 and 8plus will have higher gap between the textfield and top layout. May I know how can I set the constraint that fits for all version or other way to add for the top section and it also changed when landscape mode. Many thanks!

screenshot

Andrew
  • 75
  • 1
  • 6
  • In whole app you used navigation bar. so, it display perfect. – Jay Oct 06 '17 at 09:41
  • interface builder or code? – Lu_ Oct 06 '17 at 09:47
  • I wanted to have a long textfield with a button on top act like navigation bar... but if I using navigation bar so the size doesnt fit at all... – Andrew Oct 06 '17 at 09:48
  • @Lu_ by using storyboard... and I realise for the error "safe area layout guide before iOS 9" only workable for iOS 9 and above. too bad my app is from 8.0 above, in case I need to upgrade the deployment target? or just unchecked the safe area layout? – Andrew Oct 06 '17 at 09:52
  • like in ansver, safe area should work, or you would have to adjust your constraints and heigh when you detect iphone X – Lu_ Oct 06 '17 at 09:54

1 Answers1

0

If you are using Interface Builder you may want to update your constraints and their settings.

if #available(iOS 11.0, *) {
     if UIApplication.shared.keyWindow!.safeAreaInsets.top > CGFloat(0.0) {
         topConstraint.constant += 24
     }
 }

or

enter image description here

Lu_
  • 2,577
  • 16
  • 24
  • for the topConstraint is my UIView's top constraint when detected is iPhoneX? – Andrew Oct 06 '17 at 10:04
  • it will be a constraint for your textfield. The rest should be on top if is not relative to safe area. And overal height should be increased – Lu_ Oct 06 '17 at 10:08
  • hi, please check i appended screenshot at my post, so u mean i have to put top constraint for UIview's top, textfield's top and my button's top ? increase 24 pixels more? – Andrew Oct 06 '17 at 11:59
  • yes, that is what i believe would work for you, safe space margin does not work for me but this does – Lu_ Oct 06 '17 at 12:17
  • Hi, i tried today, its not working if i checked the safe area layout guide. Can i just change the colour for status bar ? – Andrew Oct 09 '17 at 06:10