我试图在我的视图下方找到一个阴影,从我在网上发现的情况来看,应该很简单:

shadowOffset: { width: 10, height: 10 },
shadowColor: 'black',
shadowOpacity: 1.0,

但问题是,阴影根本没有出现.

这是我的部件

<View style={styles.shadow}>
    <View style={styles.box} >
        <View style={styles.ListComponent}>
            <Text style={styles.itemText}>Livestream</Text>
        </View>
    </View>
</View>

在我的样式表中:

const styles = StyleSheet.create({
    shadow: {
    shadowOffset: { width: 10, height: 10 },
    shadowColor: 'black',
    shadowOpacity: 1.0
},

有什么原因吗,或者我错过了什么?

推荐答案

影子在IOs上工作吗?

const styles = StyleSheet.create({
shadow: {
  shadowOffset: { width: 10, height: 10 },
  shadowColor: 'black',
  shadowOpacity: 1,
  elevation: 3,
  // background color must be set
  backgroundColor : "#0000" // invisible color
}

否则,请try 为阴影组件设置背景色:)

React-native相关问答推荐

如何重复使用expo 音频对象S录音?

AxiosError:Reaction Native EXPO开发版本中的网络错误

有人可以帮我实现 Font.loadAsync

React Navigation v5 中的初始路由参数?

React Native - 当位置在Android上是绝对时视图消失

打包程序无法启动

React-Native 构建失败的应用程序:mergeDebugAssets

textAlignVertical不是有效的样式属性

React-Native Android 中隐藏(hide)的元素溢出

React native base headers for ios not found

如何在 React-Native 的alert中设置alert框标题?

使用 Jest 测试 React Native 应用程序

require() 必须有一个字符串文字参数 React Native

如果我有 AngularJS 基础知识,怎么学习Thinking in ReactJS呢?

Android 构建错误AndroidManifest.xml requires a placeholder substitution

axios 的网络错误和react-native

Native Script 与 react native 和 ionic 框架的区别

如何将 React Native Promise 连接到 Swift

使用 React Native 运行 Firebase 3.0 时出错

Gradlew bundleRelease 不会在 react-native 中生成发布 apk