U可以試試這個JS代碼.. https://snack.expo.io/r1v0LwZFb
import React, { Component } from 'react';
import { View } from 'react-native';
export default class App extends Component {
render() {
const gradientHeight=500;
const gradientBackground = 'purple';
const data = Array.from({ length: gradientHeight });
return (
<View style={{flex:1}}>
{data.map((_, i) => (
<View
key={i}
style={{
position: 'absolute',
backgroundColor: gradientBackground,
height: 1,
bottom: (gradientHeight - i),
right: 0,
left: 0,
zIndex: 2,
opacity: (1/gradientHeight) * (i + 1)
}}
/>
))}
</View>
);
}
}
最好在鏈接網站儘可能包含儘可能多的答案。按照現狀,它可能會被刪除爲「僅鏈接」的答案。查看「如何給出一個好答案」的常見問題解答。乾杯。 – stef