How to get rid of the status bar background on the UIWebView? - ios

Since iOS 11, when the UIWebView is full screen, a fake background appears on the status bar with the same color of the UIWebView background.
Anyone knows how to get rid of it?
Even adding the IUWebView to a storyboard and make it full screen will make the status bar background to appear
I've been trying to edit the size and some other properties of the UIWebView and none of them worked, but it's definitely something from the UIWebView.
Also tried to see all the subviews and it's sizes and didn't see anything strange.
Attached a screenshot, see the grey "statusbar", it disappears when scrolling, and doesn't appear if the UIWebView is not over that part of the screen.
I want it as on the second screenshot, only remove the fake background, not the status bar.

This happens because of UIScrollView new behavior to adjust the content inset to include safe area insets like the status bar.
To fix it, just set it to UIScrollViewContentInsetAdjustmentNever
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
Since iOS 11 Beta 4 you can add this to your viewport and will also remove the fake statusbar
viewport-fit=cover

To do this entirely in HTML/CSS, viewport-fit=cover in the Viewport meta tag is the correct way to handle this.
But you'll also want to adjust your padding dynamically to handle the differently sized status bar on iPhone X with its notched camera/speaker.
Luckily, Apple exposed some CSS constants for the safe area insets, so you can take advantage of those in your CSS:
i.e., padding-top: constant(safe-area-inset-top);
I wrote a bit more about this scenario and the new features for iOS 11 and iPhone X: https://ayogo.com/blog/ios11-viewport/

Swift version:
webView.scrollView.contentInsetAdjustmentBehavior = .never

Related

ios xcode capacitorjs storyboard constraint to stop status bar hanging over the top of the webview

xcode - webview content is showing in status bar
In this post, it hints that to ensure the status bar is not sitting over the webview, ie in capacitorjs's case the app, you should add constraints to the storyboard.
However, in my xcode (latest), the storyboard for capacitor "Bridge view controller" does not allow me to apply constraints.. all the options are greyed out:
However, I cannot figure out how to get the ios status bar to not sit over the top of the app, and all the old Cordova and ionic methods do not appear to be working.
Whatever I do the status bar hand over the webview..
Any ideas or ios/capacitor js pro's out there who could help?
Capacitor uses a single ViewController where the only view is a WKWebView that is full screen, so you can't add any constraints to it.
What you should do to avoid the notch is to add this viewport meta tag <meta name='viewport' content='initial-scale=1, viewport-fit=cover'> to your index.html and respect the Safe Areas with the help of env() CSS function and pre-defined environment variables safe-area-inset-left, safe-area-inset-right, safe-area-inset-top and safe-area-inset-bottom as described by Apple on this article
If your app is not going to be scrollable and you don't want to deal with the safe areas yourself, you can alternatively set the viewport meta tag to <meta name='viewport' content='initial-scale=1, viewport-fit=contain'>
and add this to the capacitor.config.json
"ios": {
"contentInset": "always"
}
I'm not familiar with Capacitor, but as an iOS developer a View Controller in not a visual element so it is not capable of having constraints.
You'll need to figure out a way to access the UIView in Capacitor and then apply constraints the the view.

Weird padding at top UINavigationController while animating to detail in iOS11

I'm posting here because I'm completely lost on this one.
I've searched all over the web, tried a lot of things myself, and searched weeks on this bug, but I can't find it.
So ever since iOS 11 (doesn't happen on iOS 10), everytime I press a button that activates the "show" segue in a UINavigationController the animation shows some weird padding at the top.
This padding disappears when the animation is finished.
I've changed the backgroundcolor of the superview to a red color, and the space you can see is indeed from the superview itself, so my guess is the whole UITableView is being moved down for some reason, although I'm not sure what exactly is the cause here.
(I'm using storyboard and AutoLayout constraints)
Another thing I noticed is that the spacing/padding you see is different on the iPhone X compared to the other devices (my guess is that it's the same height as the (non)safe area at the top? Again, not sure.
I don't think code is necessary to be provided here, as I wouldn't really know which part causes this behaviour (and there's a lot of code that I can't share for reasons..).
Any suggestions/help on how to fix this would be deeply appreciated!
Here are some examples:
iPhone X running iOS 11.1 (also happened on 11.0)
iPhone 8 gif
EDIT: I should add, some things I already tried:
tableView.contentInsetAdjustmentBehavior = .never
Setting headerviews to 0
tableView.setContentOffset(0, animated: false)
Playing with the translucency settings of the UINavigationBar
AutomaticallyAdjustContentInsets is set to false
So, as suggested by Spenser-Arn, I played around with the constraints and the Safe Areas, turns out, the safe areas where the cause of the issue.
Hope this helps other people as much as it helped me, and a big thankyou to Spenser-Arn!

Xcode Swift - iOS 10 & iOS 9 Text size problems

I've got a few buttons with text inside. If i run the app on an iOS 10 device, it works and shows the text fine. But running the app on iOS 9 the text inside the button is like "squashed" or "compressed"(the text on version 9 is missing the top and bottom part of the text). I'm not sure why this is happening, I've tried messing around with the hugging and compression settings on the UI Builder, but this hasn't really fixed the problem.
Not sure why it works on 10 but not on 9....The image above shows what the text looks like on iOS 9 ONLY!
I'm just seeing if this is happening with anyone else? or if anyone knows how to solve this problem?
I appreciate any help given! Thanks in advance!
You have to use "adjustsFontSizeToFitWidth" property of titleLabel of your button
Example:
myButton.titleLabel.adjustsFontSizeToFitWidth = YES;
There are a few possibilities:
The height of the button during runtime could be wrong. Try setting a border to the button, run and observe the button outline to see if the height is correct.
myButton.layer.borderColor = UIColor.black.cgColor
myButton.layer.borderWidth = 1
If the height is wrong, it means the constraints could be incorrectly set up.
Another possibility might be contentEdgeInsets, titleEdgeInsets properties of the button having larger than intended top and bottom values.

iOS: Launch image gets wrinkled in the center during a call/recording/hot-spot session

I use a set of launch images for my app and noticed that when I'm having a call, recording a voice note or sharing my Internet connection and put that activity in the background and launch my app, the launch screen is wrinkled in the center. Is there anything I can do to make the image look ok or is it just a standard iOS behavior?
Just define a key in plist file will solve your problem
Status bar is initially hidden = YES
OK, the solution I found is to hide status when launching the app, just like here
Seems like Apple "take" 4% of screen space from the middle of the screen (as far as I tested) to give it to status bar. Personally I faced this problem when using iPhone modem mode.
So if it is not critical for image to be centered vertically - the solution would be to place image above/below this "4% middle screen area".
Examples when image is cropped:
How image should look(image centered vertically & horizontally, width & height are fixed size)
How it actually looks
Example when image looks as supposed to (but not centered) :
Constraints example
Image with new constraints example

Centering PickerIOS in React Native

I have been trying to center a PickerIOS, but I am probably missing the underlying logic behind a Picker, because I just want its width to be full screen.
I can manage to do that with iPhone 4s / 5s, but when I run it on the iPhone 6, the Picker seems to be on the left, with some space on the right side.
I have been trying to use alignItem:'center' with a wrapper around the picker, but that just makes it disappear. I have also tried alignSelf, but still doesn't work.
I thought that Picker, by default, had its width to full screen or does it adapt according to the length of the elements?
Do I have to place it in a Flexbox in order to get it centered with a full screen width?
mask1: {
height:120,
overflow:'hidden',
justifyContent:'space-around',
marginTop:50
}
I find out that the style of PickerIOSItem cannot change, and only works fine in NavigatorIOS. I review the example of UIExplorer and there is no more style binding to the Item. Maybe it's a bug.

Resources