react native中的layoutAnimation组件

来源:互联网 发布:python 实现月份加减 编辑:程序博客网 时间:2024/05/21 13:54

layoutAnimation 只对布局的创建和更新事件起作用,对删除事件是不起作用的(如删除某个元素时,该元素会消失,可能会透明度逐渐减少 ,但是不会有其他复杂的消失)。
LayoutAnimation有以下三种动画效果类型:

  • caseInEaseOut
  • linear
  • spring

例一:

//自定义:LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);//或LayoutAnimation.easeInEaseOut();

自定义动画例二:

var CustomLayoutAnimation = {    duration: 800,    create: {      type: LayoutAnimation.Types.linear,      property: LayoutAnimation.Properties.opacity,    },    update: {      type: LayoutAnimation.Types.easeInEaseOut,    },  };LayoutAnimation.configureNext(CustomLayoutAnimation);

LayoutAnimation在ReactNative中绝对是很好的实现动画效果,完成可以和原生体验相媲美,非常值得大家一试。

[注意] 如果你在Android设备上面进行测试,那么就需要开启动画设置,iOS设备默认打开。

// Enable LayoutAnimation under Android     if (Platform.OS === 'android') {        UIManager.setLayoutAnimationEnabledExperimental(true)      }
0 0
原创粉丝点击