Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
937 views
in Technique[技术] by (71.8m points)

react native - Curved bottom on View

How can i add the curved bottom to a View in react-native? See curved example

I'f tried to a add an second view like this:

headerBottom: { width: width / 2, height: width / 2, backgroundColor: 'red', position: 'absolute', bottom: -35, left: width / 4 - 15, borderRadius: width / 4, transform: [ {scaleX: 2}, {scaleY: 0.25} ] },

I've been able to get above but rather have a less bad solution right in the same view, not as in the example in a second view.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is the result. I used Dimensions (const window = Dimensions.get('window');) here to make it more dynamic to different screen sizes.

enter image description here

const styles = StyleSheet.create({
containerStyle: {
    alignSelf: 'center',
    width: window.width,
    overflow: 'hidden',
    height: window.width / 1.7
},
sliderContainerStyle: {
    borderRadius: window.width,
    width: window.width * 2,
    height: window.width * 2,
    marginLeft: -(window.width / 2),
    position: 'absolute',
    bottom: 0,
    overflow: 'hidden'
},
slider: {
    height: window.width / 1.7,
    width: window.width,
    position: 'absolute',
    bottom: 0,
    marginLeft: window.width / 2,
    backgroundColor: '#9DD6EB'
}});


render() {
  return(
    <View style={styles.containerStyle} >
      <View style={styles.sliderContainerStyle} >
        <Slider/>
      </View>
    </View>
  );
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...