Need to make Image Bottom to corner: React Native

前端 未结 3 920
温柔的废话
温柔的废话 2021-01-27 04:29

I want to make image rounded from bottom of it. Here is what I wanted to make:

I have tried to set borderRadius, but it will apply for the whole image

3条回答
  •  野性不改
    2021-01-27 04:31

    you can add a png frame transparent with this shape on it

    also you can check this it may help the-shapes-of-react-native


    Update

    here is how I managed do this by code

    first you create this structure

    render() {
      return(
        
          
            
          
        
      );
    }
    

    and then apply this style

    const styles = {
      container: {
        alignSelf: 'center',
        marginTop: 100,
        width: 200,
        overflow: 'hidden', // for hide the not important parts from circle
        margin: 10,
        height: 100,
      },
      background: { // this shape is a circle 
        borderRadius: 400, // border borderRadius same as width and height
        width: 400,
        height: 400,
        marginLeft: -100, // reposition the circle inside parent view
        position: 'absolute',
        bottom: 0, // show the bottom part of circle
        overflow: 'hidden', // hide not important part of image
      },
      image: {
        height: 100, // same width and height for the container
        width: 200,
        position: 'absolute', // position it in circle
        bottom: 0, // position it in circle
        marginLeft: 100, // center it in main view same value as marginLeft for circle but positive
      }
    }
    

    and here is the results

提交回复
热议问题