我正在使用react-native-snap-carousel
.
我怎样才能在图像上显示文字?
<View style={styles.item}>
<ParallaxImage
source={{ uri: item.illustration }}
containerStyle={styles.imageContainer}
style={styles.image}
parallaxFactor={0.35}
{...parallaxProps}
/>
</View>
<View style={styles.textContainer}>
<Text styke={styles.title}>{item.title}</Text>
<Text style={styles.subtitle}>{item.subtitle}</Text>
</View>
款式:
const styles = StyleSheet.create({
item: {
width: screenWidth - 60,
height: screenWidth - 250
},
imageContainer: {
flex: 1,
marginBottom: Platform.select({ ios: 0, android: 1 }), // Prevent a random Android rendering issue
backgroundColor: 'white',
borderTopLeftRadius: 5,
borderTopRightRadius: 5
},
image: {
...StyleSheet.absoluteFillObject,
resizeMode: 'cover'
},
textContainer: {
justifyContent: 'center',
paddingTop: 20 - 8,
paddingBottom: 20,
paddingHorizontal: 16,
borderBottomLeftRadius: 5,
borderBottomRightRadius: 5,
backgroundColor: colors.gray3
},
title: {
color: colors.black,
fontSize: 13,
fontWeight: 'bold',
letterSpacing: 0.5
},
subtitle: {
marginTop: 6,
color: colors.gray,
fontSize: 12,
fontStyle: 'italic'
}
});