动画图像没有透明背景

时间:2020-11-03 13:29:31

标签: reactjs react-native react-animated react-native-stylesheet

在我的本机应用程序中,我想将旋转徽标呈现为屏幕的正确标题。

func namePerson(_ id String = ""){
    var name: String
    
    switch id.isEmpty {
    case false:
        name = id
    default:
        name = "No name was added"
    }
    print(name)
}

旋转器组件返回一个<Stack.Screen name="About" component={About} options={{headerRight: () => <SpinnerIcon />}} />

Animated.Image

我保存在<Animated.Image source={require('../img/reactLogoTwo.png')} style={[{width: 50, height: 50}, {transform: [{rotate}]}]} /> 文件夹中的图像具有透明背景(downloaded from here),但是动画图像具有白色背景。

enter image description here

注意:添加img无效。

1 个答案:

答案 0 :(得分:1)

我将此示例作为小吃:https://snack.expo.io/@zvona/animated-transparent-image

据此,透明PNG与Animated.Image之间没有冲突。您正在使用 react-native-animated 库吗?

其次,设置样式backgroundColor: 'transparent'可能会有所帮助,但是我看不出是什么原因导致这种特殊行为。