react-native Animated, 旋转动画
Animated 仅封装了四个可以动画化的组件:
View、Text、Image、ScrollView
可以使用 Animated.createAnimatedComponent()来封装你自己的组件。
下面是使用 Image 旋转的例子
import React, {Component} from 'react';
import { StyleSheet, View, Animated, Easing } from 'react-native';
const circle = require('../../resources/img/loginCircle.png');
class Index extends Component {
constructor(props) {
super(props);
this.spinValue = new Animated.Value()
this.state = {
};
}
componentDidMount(){
this.spin();
}
//旋转方法
spin = () => {
this.spinValue.setValue()
Animated.timing(this.spinValue,{
toValue: , // 最终值 为1,这里表示最大旋转 360度
duration: ,
easing: Easing.linear
}).start(() => this.spin())
}
render() {
const { user, pwd, fadeAnim} = this.state;
//映射 0-1的值 映射 成 0 - 360 度
const spin = this.spinValue.interpolate({
inputRange: [, ],//输入值
outputRange: ['0deg', '360deg'] //输出值
})
return(
<View style={styles.container}>
<Animated.Image style={[styles.circle,{transform:[{rotate: spin }]}]} source={circle}/>
</View>
);
}
}
const styles = StyleSheet.create({
container:{
flex:,
alignItems:'center',
justifyContent:'center',
backgroundColor:'#00a0e4'
},
circle:{
position:'absolute',
width: ,
height:
}
});
export default Index;

https://reactnative.cn/docs/0.50/animations.html#content
react-native Animated, 旋转动画的更多相关文章
- H5、React Native、Native应用对比分析
每日更新关注:http://weibo.com/hanjunqiang 新浪微博!iOS开发者交流QQ群: 446310206 "存在即合理".凡是存在的,都是合乎规律的.任何新 ...
- RN Animated透明度动画
主要代码解析: 如果我们希望吧Animated.Value从0变化到1,把组件位置从60px移动到0px,把不透明度从0编导1,就可以使用style的属性来实现 <Animated.Text s ...
- React Native 在 Airbnb(译文)
在Android,iOS,Web和跨平台框架的横向对比中,React Native本身是一个相对较新且快速开发移动的平台.两年后,我们可以肯定地说React Native在很多方面都是革命性的.这是移 ...
- Flutter vs React Native vs Native:深度性能比较
老孟导读:这是老孟翻译的付费文章,文章所有权归原作者所有. 欢迎加入老孟Flutter交流群,每周翻译2-3篇付费文章,精彩不容错过. 原文地址:https://medium.com/swlh/flu ...
- React Native动画总结
最近在使用react native进行App混合开发,相对于H5的开发,RN所提供的样式表较少,RN中不能使用类似于css3中的动画,因此,RN提供了Animated的API 1.写一个最简单的动画 ...
- React Native 学习笔记--进阶(二)--动画
React Native 进阶(二)–动画 动画 流畅.有意义的动画对于移动应用用户体验来说是非常必要的.我们可以联合使用两个互补的系统:用于全局的布局动画LayoutAnimation,和用于创建更 ...
- React Native填坑之旅--动画
动画是提高用户体验不可缺少的一个元素.恰如其分的动画可以让用户更明确的感知当前的操作是什么. 无疑在使用React Native开发应用的时候也需要动画.这就需要知道RN都给我们提供了那些动画,和每个 ...
- 【React Native】进阶指南之一(特定平台、图片加载、动画使用)
一.特定平台代码 React Native提供了两种方法来区分平台: 使用Platform模块: 使用特定平台扩展名: 1.Platform模块 React Native提供了一个检测当前运行平台的模 ...
- 【React Native 实战】旋转图片验证码
1.前言蘑菇街用打乱方向的图片作为验证码,既起到了验证码的作用又宣传了图片,今天我们就用React Native来实现这样的功能. 2.属性 Image标签属性resizeMode enum('cov ...
随机推荐
- Excel导入MS SQL SERVER 操作
关于Excel导入到sql操作的相关问题总结: 一.大批量数据导入 方法1.从Excel大批量数据导入时我们可以使用sql里面有一个batch copy的功能 方法2.在sql中建一个table ty ...
- P1706 全排列问题
题解:(其实我认为它就是个循环) #include<iostream> #include<cstdio> #include<iomanip> using names ...
- hadoop 完全分布式安装
一个完全的hadoop分布式安装至少需要3个zookeeper,3个journalnode,3个datanode,2个namenode组成. 也就是说需要11个节点,但是我云主机有限,只有3个,所以把 ...
- ipv6下jdbc的连接数据库方式
ipv6下jdbc的连接数据库方式 MySQL: ipv4 Driver URL: jdbc:mysql://127.0.0.1:3306/database ipv6 Driv ...
- go语言学习--map类型的切片
今天在项目中遇到了一个切片的map,记录下map切片的使用 package main import "fmt" func main() { // Version A: items ...
- ROS routeros mikrotik路由器CVE-2018-14847漏洞
原文: https://securitynews.sonicwall.com/xmlpost/massive-cryptojacking-campaign/ SonicWall is observin ...
- SpringMVC 请求响应流程
SpringMVC的工作原理图: SpringMVC流程 1. 用户发送请求至前端控制器DispatcherServlet. 2. DispatcherServlet收到请求调用HandlerMa ...
- CyclicBarrier循环屏障相关
简介 CyclicBarrier 的字面意思是可循环使用(Cyclic)的屏障(Barrier).它要做的事情是,让一组线程到达一个屏障(也可以叫同步点)时被阻塞,直到最后一个线程到达屏障时,屏障才会 ...
- sqlserver in 和 exist 子查询
1 in 子查询 use StudentManageDB go --select StudentName from Students --where StudentId=(select Student ...
- typescript类与继承
/* 1.vscode配置自动编译 1.第一步 tsc --inti 生成tsconfig.json 改 "outDir": "./js", 2.第二步 任务 ...