react-native-view-shot icon indicating copy to clipboard operation
react-native-view-shot copied to clipboard

The image doesn't have a transparent background

Open Pietro-Putelli opened this issue 1 year ago • 2 comments

I am using the library to save a screenshot of a view, whose height is not initially defined, as I am using padding and setting the height of the view using the onLayout method.

The problem is that the image saved has a white background color, which I want to remove.

      <View
        onLayout={(e) => {
          setHeight(e.nativeEvent.layout.height);
        }}
        ref={contentRef}
        style={{
          height,
          padding:16,
          width: width-12,
          backgroundColor: "darkblue",
          borderRadius: 32,
        }}
      >
        <Text style={{color:"white"}}>This is a test using padding</Text>
      </View>

Expo Snack to reproduce the issue

Pietro-Putelli avatar Jan 13 '23 01:01 Pietro-Putelli

I have the same problem. Android works great, but iOS adds the white background for some reason

Antonio-Melo avatar Jan 27 '23 22:01 Antonio-Melo

@Antonio-Melo Try to with type png.

MaruanBO avatar Jul 14 '23 08:07 MaruanBO