Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native - how to make a border image?

I want to make a border image to a View , similar to border-image in the css.

How could I achieve it ?

like image 685
URL87 Avatar asked May 15 '18 06:05

URL87


2 Answers

You can use ImageBackground component of react-native and wrap your view inside component by adding some padding around your nested view

<ImageBackground source={imageSource}>
 <Text style={{padding:20}}> Inside </Text>
</ImageBackground>
like image 83
Muhammad Shoaib Riaz Avatar answered Sep 19 '22 20:09

Muhammad Shoaib Riaz


I believe that if you use Styled Components (https://www.styled-components.com/) you can set it with CSS directly. It will be something like this:

import styled from 'styled-components/native';

const StyledView = styled.View`
  border-image: <your definition here>;
`;

And then simply use it like you always do:

<StyledView>

</StyledView>

Hope it helps!

like image 23
Droow Avatar answered Sep 20 '22 20:09

Droow