javascript - 存在导航栏时如何在顶部屏幕上显示动画?
问题描述
我想在导航标题栏上方显示动画..
但它显示在标题栏下方。
我也使用了 zIndex,但它不起作用。
我还附上了一张我得到的结果的图片。
这是在 App.js 中,我刚刚设置了导航屏幕
import MainScreen from "./screens/MainScreen";
import SecondScreen from "./screens/SecondScreen";
import ThirdScreen from "./screens/ThirdScreen";
import FourthScreen from "./screens/FourthScreen";
const AppNavigator = createStackNavigator({
FourthScreen: {
screen: FourthScreen
},
SecondScreen: {
screen: SecondScreen,
},
ThirdScreen: {
screen: ThirdScreen
},
MainScreen: {
screen: MainScreen
}
})
const App = createAppContainer(AppNavigator);
export default App;
在 FourthScreen.js 中,这是想要做动画的屏幕。
import React, { Component } from 'react';
import {Text, Animated, View} from "react-native";
class FourthScreen extends Component {
static navigationOptions = {
title: "Screen Title",
headerTitleStyle: {
textAlign: "center",
flex: 1
},
}
constructor(props) {
super(props);
this.state = { }
}
componentWillMount(){
this.position = new Animated.ValueXY(0,0);
Animated.spring(this.position, {
toValue: {x: 0, y: -50}
}).start();
}
render() {
return (
<Animated.View style={this.position.getLayout()}>
<View style= {styles.ball} />
</Animated.View>
);
}
}
const styles = {
ball: {
height: 60,
width: 60,
borderRadius: 30,
borderWidth: 30,
borderColor: "black",
zIndex: 100,
position: "absolute"
}
}
export default FourthScreen;
解决方案
推荐阅读
- c# - OpenXml 和奇怪的行为
- perl - 这个表达式中的优先级是什么?
- python - 使用 Matplotlib 绘制网格中加权单元的矩阵
- java - 具有多个视频选项卡的活动同时播放
- merge - SAS:来自不同表的连接列(相同的行数)
- java - 来自通知点击的用户
- php - 注册后自动登录
- hybris - 在 PLP 上单击基础产品时配置最低价格产品
- gitlab-ci - git clone 在 gitlab runner docker 中失败
- raspberry-pi - system/core/include/utils/String16.h:20:10:致命错误:找不到“字符串”文件