동일한 아이디어에 관심이 있습니다. 사용자가 아래로 스크롤 할 때 머리글의 배경색을 변경하고 싶습니다. 애니메이션 API를 사용하고 있지만 계속 경고 메시지가 표시되고 작동하지 않습니다. 이것이 내가 시도한 것이다. 나는 다음과 같은 코드가 화면에
:
constructor(props) {
super(props);
this.scrollY = new Animated.Value(0);
}
componentWillMount() {
this.props.navigation.setParams({
bgColor: this.scrollY.interpolate({
inputRange: [0, SCREEN_HEIGHT/2 - 40],
outputRange: ['transparent', 'rgb(255,255,255)'],
extrapolate: 'clamp',
}),
});
}
render() {
return (
<ScrollView
style={{ backgroundColor: 'black' }}
contentContainerStyle={{ flexGrow: 1 }}
onScroll={Animated.event([
{ nativeEvent: { contentOffset: { y: this.scrollY } } },
])}
scrollEventThrottle={16}
>
<View>
.....
}
또한 다음 navigationOptions 있습니다
navigationOptions: ({ navigation }) => ({
tabBarVisible: false,
headerStyle: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
backgroundColor: !navigation.state.params
? 'transparent'
: navigation.state.params.bgColor,
borderBottomWidth: 0,
elevation: 0,
},
}),
Warning Warning-cont
을