TouchableHighlight簡單使用

//相當於button使用
<TouchableHighlight
//點擊後的背景顏色
underlayColor="#1FB579"
//設置點擊事件
onPress={hanwanjie}
style={styleObj.loginButton}>
<Text style={styleObj.loginButtonText}>登錄</Text>
</TouchableHighlight>

//登錄按鈕的點擊事件
const hanwanjie = () => {
console.log('點擊登錄按鈕');
}

const styleObj = StyleSheet.create({
//登錄按鈕樣式
loginButton:{
backgroundColor:'#1fd094',
width:screenWidth*0.6,
height:45,
marginTop:30,
alignItems:'center',
borderRadius:8,
},
//登錄文字設置
loginButtonText:{
color:'#ffffff',
fontSize:18,
lineHeight:42,
fontWeight:'bold',
},

});

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章