How to show the only part of the image

前端 未结 1 1681
耶瑟儿~
耶瑟儿~ 2021-01-04 23:31

UPDATE Since the question was complicating and unclear, I\'m rewriting my question to make it much simpler.

Given

1条回答
  •  猫巷女王i
    2021-01-04 23:49

    Here is a working example: https://snack.expo.io/@zvona/cropped-image

    The idea is to have "cropped" View where Image is positioned inside it with custom dimensions. I use constants in my example to clarify the case.

    
      
    
    

    And on styles:

      image: {
        marginLeft: -OFFSET_LEFT,
        marginTop: -OFFSET_TOP,
        width: IMAGE_WIDTH,
        height: IMAGE_HEIGHT,
      },
    
      cropped: {
        width: 150,
        height: 150,
        overflow: 'hidden',
        position: 'absolute',
        left: OFFSET_LEFT,
        top: OFFSET_TOP,
      },
    

    Note that ImageBackground is only for example purposes and it's not needed in the actual implementation.

    0 讨论(0)
提交回复
热议问题