1

In my react-native application, I want to render a spinning logo as the right header for a screen.

<Stack.Screen
      name="About"
      component={About}
      options={{headerRight: () => <SpinnerIcon />}}
    />

And the spinner component returns an Animated.Image

<Animated.Image
        source={require('../img/reactLogoTwo.png')}
        style={[{width: 50, height: 50}, {transform: [{rotate}]}]}
      />

The image I have saved in img folder has a transparent background (downloaded from here) but the animated image rendered with a white background.

enter image description here

Notes: adding backgroundColor: 'transparent' does not work.

Amir-Mousavi
  • 4,273
  • 12
  • 70
  • 123

1 Answers1

1

I made this example as Snack: https://snack.expo.io/@zvona/animated-transparent-image

According to it, there's no conflict between transparent PNG's and Animated.Image. Are you using react-native-animated library?

Secondarily, setting style backgroundColor: 'transparent' might help, but I don't see what could cause that peculiar behavior.

Samuli Hakoniemi
  • 18,740
  • 1
  • 61
  • 74