我的想法有点不同:有一个包装纸
View
组件),并将日历图标用作其“背景图像”。然后将动态日期编号放置在此包装的中间:
<View style={styles.calendar}>
<MaterialCommunityIcons name="calendar-blank" size={30} color="#000" style={styles.calendarIcon} />
<Text style={styles.date}>21</Text>
</View>
款式:
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
},
calendar: {
position: 'relative',
alignItems: 'center',
justifyContent: 'center',
width: 30,
height: 30,
},
calendarIcon: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0
},
date: {
fontSize: 9,
marginTop: 4
}
});
这是一个工作
example