그라데이션을 적용할 수 있는 라이브러리 react-native-linear-gradient를 사용해보자.
Installation
Using Yarn
yarn add react-native-linear-gradient
Using npm
npm install react-native-linear-gradient --save
Linking
만약 react-native version이 0.60 아래라면 Linking 필요!
react-native link react-native-linear-gradient
후에는 https://github.com/react-native-linear-gradient/react-native-linear-gradient 에 들어가 메뉴얼을 확인해보자.

설치가 다 되었다면 사용해보자.
const linearColors = [startBgColor, endBgColor];
return <LinearGradient
colors={linearColors}
style={{
width: '100%',
height: '100%',
position: 'absolute',
zIndex: 100,
alignItems: 'center',
justifyContent: 'center',
}}/>
startBgColor와 endBgColor에 RGBA 색상이나 Hex 값만 정해주면 된다!
ex) ['#FFFFFF', '#0D0D0D']
이렇게 지정해주면 배경색이 그라데이션으로 적용된 것을 볼 수 있다.
'React-Native' 카테고리의 다른 글
[React native] android 릴리즈 모드에서 network error (0) | 2023.02.24 |
---|---|
[react-native] 앱 종료 시 BackHandler VS react-native-exit-app (0) | 2023.02.07 |
[React-Native] useWindowDimensions 화면 크기 대응 (0) | 2022.12.27 |
React Hook - useState를 활용하여 탭 구성하기 (2) | 2022.12.24 |
[React-Native] 해당 조건에만 여러 스타일 지정해주기 (props 안에서 중복 조건 추출) (0) | 2022.12.17 |