【发布时间】:2019-02-06 00:29:38
【问题描述】:
我正在通过 TouchableOpacity 设计自定义按钮以响应本机。到目前为止,我尝试了不同的样式方法,但没有得到所需的设计。下面提到的是我尝试解决的问题。
<TouchableOpacity style={styles.numericButton}>
<View>
<Text style={styles.numericButtonText}>1</Text>
</View>
</TouchableOpacity>
const styles = StyleSheet.create({
numericButton: {
margin:10,
padding:10,
backgroundColor:'#D3D3D3',
borderColor:'#000',
borderWidth:2,
borderRadius:5,
elevation:10,
shadowOffset: { width: 5, height: 5 },
shadowColor: "black",
shadowOpacity: 1,
shadowRadius: 5,
},
numericButtonText:{
fontSize:24,
fontWeight:'bold',
fontFamily:'Cochin'
}
});
结果:
我想像这样设计我的 react native 按钮
【问题讨论】:
-
React Native 的样式功能非常有限,实现这种照明效果的唯一方法可能是使用图像
-
@kai 你能推荐我任何可以在 react native 中提供这种样式的第三方库吗?
-
React Native 不提供渐变。有图书馆供您使用。 react-native-liner-gradient github.com/react-native-community/react-native-linear-gradient 不过,我也推荐使用 image。
标签: react-native react-native-stylesheet