鱼C论坛

 找回密码
 立即注册
查看: 3043|回复: 0

[技术交流] RN动画制作之系列动画

[复制链接]
发表于 2017-8-11 11:12:40 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import React, { Component } from 'react';
  2. import {
  3.   AppRegistry,
  4.   Button,
  5.   View,
  6.   Animated,
  7.   StyleSheet
  8. } from 'react-native';

  9. export default class myreact extends Component {
  10.   constructor(props) {
  11.     super(props);
  12.     this.state = {
  13.       a:new Animated.Value(0),
  14.       b:new Animated.Value(0),
  15.       c:new Animated.Value(0),
  16.       d:new Animated.Value(0),
  17.       e:new Animated.Value(0)
  18.       }
  19.    
  20.     };
  21.   render() {   
  22.     return (
  23.       <View style={{flex:1}}>
  24.       <Animated.View style={styles.contianer}>
  25.         <Animated.Text style={[styles.text,{opacity: this.state.a}]}>鱼</Animated.Text>
  26.         <Animated.Text style={[styles.text,{opacity: this.state.b}]}>C</Animated.Text>
  27.         <Animated.Text style={[styles.text,{opacity: this.state.c}]}>工</Animated.Text>
  28.         <Animated.Text style={[styles.text,{opacity: this.state.d}]}>作</Animated.Text>
  29.         <Animated.Text style={[styles.text,{opacity: this.state.e}]}>室</Animated.Text>
  30.       </Animated.View>
  31.       <Button onPress={()=>{
  32.           this.setState({
  33.             a:this.state.a,b:this.state.b,
  34.             c:this.state.c,d:this.state.d,
  35.             e:this.state.e
  36.           })

  37.           Animated.sequence([            
  38.           Animated.timing(this.state.a, {   
  39.             toValue:1,
  40.             duration:1000
  41.           }),                  
  42.           Animated.timing(this.state.b, {   
  43.             toValue:1,
  44.             duration:1000
  45.           }),
  46.           Animated.timing(this.state.c, {   
  47.             toValue:1,
  48.             duration:1000
  49.           }),
  50.           Animated.timing(this.state.d, {   
  51.             toValue:1,
  52.             duration:1000
  53.           }),
  54.           Animated.timing(this.state.e, {   
  55.             toValue:1,
  56.             duration:1000
  57.           })                        
  58.           ]).start();
  59.         }}
  60.         title="press me"
  61.         color="#841584"
  62.       />
  63.       </View>
  64.     );
  65.   }
  66. }
  67. var styles=StyleSheet.create({
  68.   contianer:{
  69.     flex:1,backgroundColor: 'lightblue',
  70.         flexDirection: 'row',
  71.         alignItems: 'center',
  72.         justifyContent: 'center' ,
  73.   },
  74.   text:{
  75.     fontSize: 50,
  76.     color: 'green',
  77.     fontFamily: '微软雅黑'
  78.   }
  79. })
  80. AppRegistry.registerComponent('myreact', () => myreact);
复制代码

这就是系列动画,效果图为:
jdfw.gif
做手机app是非常麻烦的,因为只是个新手入门系列,这个系列教程就讲到这里,里面有好多错误希望大家指出。还有其他的一些控件,比如listview都是相当好用,还有跨域获取其他网站的数据fetch,手机数据库syncstorage等都是简单好用,各位都可以自己以后深入的研究,有想继续学的鱼油可以去https://reactnative.cn/docs/0.47/getting-started.html这个中文官方网站,这是我找到的最好的学react native的官网。因为这是去年脸谱网站才发明出来的新技术,有些技术还不是太成熟,难度方面我觉得也不次于用java做android,而且还必须要联网才行,对于中国大部分地区还没有上网条件来说还不会太普及这项技术,主流还是应该java。也许将来我会在java板块做个用java做android手机app的教程,话说还是纯原生的比较好

本帖被以下淘专辑推荐:

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-20 05:07

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表