I'm creating an app in React Native that uses react-navigation.
I have some views that animate off the screen towards the top of the screen. While animating, the view goes behind the react-navigation navigation header. It goes behind the iOS status bar, but the status bar is translucent, so it shows the status bar text on top of the view. The status bar is no longer white, but the color of the view under it.
This doesn't look right and I would like the status bar to be always on top and not translucent. What is the best way to go about this?
I was finally able to avoid content overlapping the status bar by placing this element in my topmost container:
<View
style = {{
height: 20,
width: width,
backgroundColor: 'white',
zIndex: 3,
position: 'absolute',
top: 0,
left: 0,
}}
/>
The status bar still shows but animated content never overlaps it.
It's because your react-navigation header has a elevation property, that works strangely (i think just in some cases) as a zIndex in Android, you probably can fix this by adding a higher zIndex to your iOS status bar than you have in the animation.
EDIT: Solved in How to set iOS status bar background color
Related
The toolbar's translucent is false. The color of the toolbar and the area below toolbar is white. When pushing a new view controller of the same class(both have toolbar in the bottom), the color of the area below toolbar will be changed to gray and then back to white at the end.
If I set the background color for the navigation controller or the key window to red, the red color will also be darkened a little bit during transition.
This problem occurs in iOS 13, 14, 15, and maybe present from the beginning since the introduction of iPhone X.
Any help is welcome, thanks in advance.
-Xiang
It seems during push transition, the old tableview are also grayed, which make the area below toolbar become gray.
My final solution is to make the toolbar extend to outside safe area by setting clip bounds to false.
I am trying to get the icons in the tab bar to be brought down more into the middle of the bar. I have tried setting the image insets in the story board as well as through code and none of it is working.
I'm currently using iOS 15 + Xcode 13.1.
EX: (top: 6, right: 0, bottom: -6, left: 0)
This is an example of the code I attempted as well:
tabBar.items?[0].imageInsets = UIEdgeInsets(top: 6, left: 20, bottom: -6, right: 0)
This is a picture of the current state. You'll see that even without a title, all the icons float to the top of the bar and I want them to be aligned lower in the bar.
I am not 100% sure but as far as I know there is no way to change it's alignment.
I would not recommend modifying the native tab bar. If you definitely want to update the position of tab bar items I encourage you to use a custom tab bar. You will have a lot more control over how it behaves and you will avoid any hacky solution.
I am working on a "drawer menu" component. The menu is an overlay that comes form the side and partially covers the main screen.
Is it possible to make it partially cover the status bar too? I have seen this effect in Google Inbox.
Yes, it is possible to make it partially cover the status bar. You can create a view component and you can position it with an absolute position. Based on this library, you can add this style to a view component
{
right: 0,
left: 0,
top: 0,
bottom: 0,
position: 'absolute',
backgroundColor: 'transparent'
}
Then you can add a custom width to the same view so the drawer doesn't take all the screen width.
You can also use the react-native DrawerLayoutAndroid, but this component is only available on android.
First, look at the picture below.
The middle is the message app, the left and right are my apps.
As you can see, in the message app, the status bar and top bar are both grey.
In the left one, the top bar is not translucent. The status bar and the top bar are all white.
In the right one, the top bar is translucent, which is the default style. The top bar is grey, but the status bar is white.
My question is, how to set the status bar to grey? As I can see in the target info part, the status bar style is already 'grey style(default). But it runs in white in my iPhone 5 iOS 7.1.1.
It turns out that #Panayot Panayotov is right. In Navigation controller, everything is fine.
I have compared the Navigation controller and Navigation bar alone. It turns out that in Navigation controller, the Navigation bar's x, y, width and height is 0, 0, 0, 0, which means it is right behind the status bar and also with a autolayout size. Since the status bar is translucent in iOS7, the color of the status bar and navigation bar are the same.
If you use Navigation bar alone, it has a fixed height 44, which can not be changed. That height can't cover the status bar and navigation bar items together. So they colors are different.
Finally the answer is to use navigation controller, not using navigation bar alone.
I'm all out of ideas on how to get this to work.
I need the status bar to match the colour of the Nav bar, with the Nav bar being transparent.
For some reason however, it's only working for 3 quarters of the status bar.
Here it is in portrait. With the slide in masterView's status bar being black.
And landscape. No idea why it's black at the far right.
Does anyone know why it would be doing this? The status bar is supposed to take on the colour of the navigation bar. But it just isn't working.
I've tried setting background images to the Navigation Bars.
I've tried setting a colour to the Navigation Bar background.
This is the code in my AppDelegate that adds the blue to the status bar.
UIView *statusBarBlue = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.window.frame.size.width, 20)];
[statusBarBlue setBackgroundColor:[UIColor colorWithRed:0.219 green:0.554 blue:0.719 alpha:1.000]];
[self.window.rootViewController.view addSubview:statusBarBlue];
Opening up a new project and pasting that code in to your AppDelegate will get the same thing I'm seeing.
If I extend the width of the statusBarBlue view, to say like 2000, the black status bar in the landscape is removed.
However, in portrait, the black is still there.
I'm all out of ideas. Any nudges in the right direction would be very helpful.
I managed to get this to work by just setting the navigation bar colour.