0
我試圖根據他們的觸摸狀態添加樣式到不同的圖像。我正在努力尋找一種適用於android和ios的解決方案,爲圖像添加邊框陰影。在網絡上,我使用了box-shadow來做到這一點,但是這個選項在RN上不起作用。到目前爲止,我已經試過海拔(不知道如果我正確地使用這個,因爲它似乎並沒有做太多?)和則shadowColor但既不是做什麼我需要它反應本機盒陰影解決方案的圖像
import React, { Component } from 'react';
import { TouchableWithoutFeedback, Image, Alert } from 'react-native';
import { View, Text } from 'native-base';
class Answer extends Component {
render() {
const { option, onClickCallback, isSelected, isBlurred } = this.props;
const {
cssUnSelected,
cssSelected,
cssBlurred,
image
} = styles;
let mode = 'contain';
let cssSelection = cssUnSelected;
if (isSelected) {
cssSelection = cssSelected;
}
if (isBlurred) {
cssSelection = cssBlurred;
}
return (
<View style={cssSelection}>
<TouchableWithoutFeedback onPress={onClickCallback}>
<Image source={require('../../assets/imgs/draw90.png')}
resizeMode={mode}
style={image} />
</TouchableWithoutFeedback>
</View>
)
}
}
const styles = {
cssSelected: {
borderRadius: 100,
elevation: 90,
shadowColor: "green"
},
cssUnSelected: {
borderRadius: 100,
elevation: 90,
shadowColor: "blue"
},
cssBlurred: {
elevation: 10,
borderRadius: 100,
opacity: 0.5,
shadowColor: "red"
},
image: {
flex: 1,
marginLeft: "1%",
marginRight: "1%",
maxWidth: 90
}
}
export default Answer;
謝謝您的回答拉維。所以我試圖建立的設計基於它們的觸摸狀態具有不同的彩色陰影。看起來我可能不得不回去設計這個! – jSutcliffe90