IT TIP

배경색으로 네이티브 테두리 반경 반응

itqueen 2020. 10. 20. 19:02
반응형

배경색으로 네이티브 테두리 반경 반응


React Native에서 borderRadius작동하지만 버튼에 지정된 배경색이 정사각형으로 유지됩니다. 여기서 무슨 일이 일어나고 있습니까?

JS

<TouchableHighlight
  style={styles.submit}
  onPress={() => this.submitSuggestion(this.props)}
  underlayColor='#fff'>
    <Text style={[this.getFontSize(),styles.submitText]}>Submit</Text>
</TouchableHighlight>

스타일

...
submit:{
    marginRight:40,
    marginLeft:40,
    marginTop:10,
},
submitText:{
    paddingTop:20,
    paddingBottom:20,
    color:'#fff',
    textAlign:'center',
    backgroundColor:'#68a0cf',
    borderRadius: 10,
    borderWidth: 1,
    borderColor: '#fff'
},
...

여기에 이미지 설명 입력


버튼 스타일을 TouchableHighlight자체로 이동해보십시오 .

스타일 :

  submit:{
    marginRight:40,
    marginLeft:40,
    marginTop:10,
    paddingTop:20,
    paddingBottom:20,
    backgroundColor:'#68a0cf',
    borderRadius:10,
    borderWidth: 1,
    borderColor: '#fff'
  },
  submitText:{
      color:'#fff',
      textAlign:'center',
  }

버튼 (동일) :

<TouchableHighlight
  style={styles.submit}
  onPress={() => this.submitSuggestion(this.props)}
  underlayColor='#fff'>
    <Text style={[this.getFontSize(),styles.submitText]}>Submit</Text>
</TouchableHighlight>

여기에 이미지 설명 입력


overflow: hidden스타일에 추가 해야합니다.

Js :

<Button style={styles.submit}>Submit</Button>

스타일 :

submit {
   backgroundColor: '#68a0cf';
   overflow: 'hidden';
}

아래 코드 줄을 적용하십시오.

<TextInput
  style={{ height: 40, width: "95%", borderColor: 'gray', borderWidth: 2, borderRadius: 20,  marginBottom: 20, fontSize: 18, backgroundColor: '#68a0cf' }}
  // Adding hint in TextInput using Placeholder option.
  placeholder=" Enter Your First Name"
  // Making the Under line Transparent.
  underlineColorAndroid="transparent"
/>

참고 URL : https://stackoverflow.com/questions/35030758/react-native-border-radius-with-background-color

반응형