我想为一个View
创建一个类似于CSS中的border-image边框图像。
我该如何实现?
我相信如果你使用Styled Components(https://www.styled-components.com/),你可以直接用CSS来设置它。大致的代码如下:
import styled from 'styled-components/native';
const StyledView = styled.View`
border-image: <your definition here>;
`;
然后像往常一样使用它:
<StyledView>
</StyledView>
<ImageBackground source={imageSource}>
<Text style={{padding:20}}> Inside </Text>
</ImageBackground>
<Image
style={{
backgroundColor: '#ccc',
position: 'absolute',
width: '100%',
height: '100%',
justifyContent: 'center'
}}
source={{ uri: 'path/to/your/image/of/border' }}
>
<Text
style={{
backgroundColor: 'transparent',
textAlign: 'center',
fontSize: 30,
padding: 40,
}}
>
{text}
</Text>