React Native + Android:borderRadius替代?

时间:2017-05-18 10:30:18

标签: react-native

我需要在非纯色背景上制作View圆形。

我尝试使用borderRadiusoverflow: 'hidden',但它无效。我发现这是React Native的一个已知问题:https://github.com/facebook/react-native/issues/3198

似乎有固定背景上的图像的变通方法,但我的背景是动态的,并且在图像之上,因此我无法对其进行硬编码。

有没有其他方法可以让这样的东西起作用?

黑色正方形应为圆形:

enter image description here

这是代码(P.S。我正在使用本地webrtc,我正在获取RTCView,但我认为这适用于普通的View):

const styles = StyleSheet.create({
  remoteVideoContainer: {
    borderRadius: 50,
    height: 100,
    marginBottom: 20,
    width: 100,
    overflow: 'hidden',
    backgroundColor: 'green',
  },
  video: {
    flex: 1,
    resizeMode: 'cover',
    backgroundColor: 'blue',
  },
});

export default VideoView = ({
  videoURL,
}) => {
  return (
    <View style={styles.remoteVideoContainer}>
      <RTCView
        style={styles.video}
        streamURL={videoURL}
        mirror={true}
        objectFit="cover"
      />
    </View>
  );
};

1 个答案:

答案 0 :(得分:0)

我甚至不确定你是否可以设置RTCView的样式。代码不会暴露样式道具。 https://github.com/oney/react-native-webrtc/blob/master/RTCView.js

相关问题