react native 闪屏页(启动页)封装
来源:互联网 发布:c 语言整型常量 编辑:程序博客网 时间:2024/05/29 18:30
基本上大部分app都会有一个闪屏页(启动页),下面我们就封装一下,要求:
- 一张图片透明度在1500ms时间内由0.4变化为1。
- 提供图片source和动画执行完毕的回调。
/** * Created by on 2017/3/24. * 闪屏页,一般的项目都会带闪屏页 * 1.5秒渐变后跳到主页 */import React, {Component, PropTypes,} from 'react';import { StyleSheet, View, Animated, Image, Dimensions,} from 'react-native';var WINDOW_WIDTH = Dimensions.get('window').width;export default class Splash extends Component { static propTypes = { //图片资源 source: Image.source, //动画执行完毕回调 animateEnd: PropTypes.func, } constructor(props) { super(props); this.state = { fadeAnim: new Animated.Value(0.4), }; } componentDidMount() { const {animateEnd} = this.props; Animated.timing( this.state.fadeAnim, { toValue: 1, duration: 1500, } ).start(() => { //动画执行完毕 if (animateEnd) { animateEnd() } }); } render() { const {source} = this.props; return ( <View style={{flex:1}}> <Animated.Image style={{flex:1,width:WINDOW_WIDTH,height:1,opacity: this.state.fadeAnim}} source={source}/> </View> ); }}
demo:
_animateEnd = ()=>{ //动画完成的回调 } render() { return ( <Splash source={require('../res/imgs/splash.png')} animateEnd={this._animateEnd}/> ); }
阅读全文
0 0
- react native 闪屏页(启动页)封装
- react native封装UI
- react native Toast封装
- react-native http封装
- react-native modal封装
- React Native 控件封装
- React Native TableViewCell封装
- React Native模拟APP启动介绍页
- react-native 组件封装示例
- react-native--万能Button封装
- react native 封装Touchable 组件
- react native Back 按钮封装
- react native 密码控件 封装
- React Native 富文本封装
- React Native 原生模块封装、发布、调用 (Android)
- react native 不能启动 genymotion
- React-Native 启动时报错
- React-Native初体验二(window环境下实现启动页)
- 成员变量,静态变量,静态块,静态方法执行顺序
- oracle的聚集函数wm_concat()和listagg()不适用时,自定义通用的聚集函数合并查询结果列
- history.back(-1)和history.go(-1)的区别
- BitmapShader实现圆形头像
- 【数据结构】二叉树前序、中序、后序遍历相互求法
- react native 闪屏页(启动页)封装
- freeswitch cdr记录落地mysql
- git
- 动态生成标签栏和Fragment,动态数据插入填充,似今日头条
- 关于JUnit无法读取到方法总结
- 解决Debug JDK8源码无法查看局部变量的问题
- DefaultAnnotationHandlerMapping 和 AnnotationMethodHandlerAdapter过时
- U3D -- 图集分割和使用
- ssm 线程