styles - How to render a star rate component in react-native? -
how can create half colored star?
<image source={require('../star.png')} style={{ height: '100%', aspectratio: 1, tintcolor: 'blue', backgroundcolor: 'transparent' }} />
is possible have background view , use image mask?
tried following fails.
<view style={styles.container}> <view style={{ position: 'absolute', backgroundcolor: 'blue', width: '80%', height: '100%' }} /> <image source={require('../star.png')} style={{ height: '100%', aspectratio: 1, tintcolor: 'transparent', }} /> </view>
you can use component this. should find image of star out of stars must filled color , background color of stars must trasparent. assume width of each star 30 in example. should pass rate value prop
export default class starrate extends component { render() { return ( <view style={{height: 30, width: 150}}> <view style={{ position: 'absolute', backgroundcolor: 'yellow', height: 30, width: this.props.rate*30, }} /> <image source={require('../star.png')} style={{ position: 'absolute', left: 0, top: 0, height: 30, width: 150, }} /> </view> ); } }
Comments
Post a Comment