如何在react-native中为View创建嵌入阴影 - iOS,Android?

时间:2017-10-22 06:44:21

标签: react-native shadow

有没有办法在反应原生中为视图创建插入阴影?

2 个答案:

答案 0 :(得分:1)

试试这个:

const styles = StyleSheet.create({
containerStyle: {
  borderWidth: 1,
  borderRadius: 2,
  borderColor: '#ddd',
  borderBottomWidth: 0,
  shadowColor: '#000',
  shadowOffset: { width: 0, height: 2 },
  shadowOpacity: 0.8,
  shadowRadius: 2,
  elevation: 1,
  marginLeft: 5,
  marginRight: 5,
  marginTop: 10,
}
})

答案 1 :(得分:0)

function currencyFormat(num) {
  if (isNaN(num)) {
    return "";
  }
  return num.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
}

function onlyDecimal(ControlId) {
  $(ControlId).on('keyup', function(key) {
    if (this.value != this.value.replace(/[^0-9\.,]/g, '')) {
      this.value = this.value.replace(/[^0-9\.,]/g, '');
    }
  })
};
$(document).on('click', '#addRow', function(e) {
  var html = '';
  html += '<tr>'
  html += '<td><input class="qty" type="text" onblur="this.value=currencyFormat(parseFloat(this.value));" onkeyup="onlyDecimal(this)"></td>';
  html += '<td><input class="price" type="text" onblur="this.value=currencyFormat(parseFloat(this.value));" onkeyup="onlyDecimal(this)"></td>';
  html += '</tr>'

  $('.table').append(html);
});

我正在使用 expo 线性渐变,保留背景“#777”以获得更好的外观