Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Negative shadowOffset to create top shadow

Tags:

react-native

I am trying to create a bottom navigation bar like YouTube or Instagram have but I am running into issue creating the shadow effect:

This is my current code;

  shadowColor: '#000000',
  shadowOffset: {
    width: 0,
    height: 0
  },
  shadowRadius: 50,
  shadowOpacity: 1.0,
  elevation: 1

This produces a shadow that is only visible on the bottom of the navigation bar but not on the top. Is there a way to place a negative shadowOffset so that the shadow is also visible on the top?

Example:

enter image description here

like image 480
Blezx Avatar asked Jun 27 '17 23:06

Blezx


1 Answers

You can add small marginTop to your container, than add styles:

{
  shadowRadius: 2,
  shadowOffset: {
    width: 0,
    height: -3,
  },
  shadowColor: '#000000',
  elevation: 4,
}
like image 106
Olya Pischik Avatar answered Sep 17 '22 19:09

Olya Pischik