iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 16
0

為什麼人家的TabBar都可以有動畫QAQ

import LottieView from 'lottie-react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';

https://ithelp.ithome.com.tw/upload/images/20200929/20104220ugLEwAHy0j.png

https://ithelp.ithome.com.tw/upload/images/20200929/20104220jTJIfxjqLi.png

看看這個可愛的小icon 好想要啊 ԅ(¯﹃¯ԅ)

import React from 'react';
import { Button, Text, View, Image } from 'react-native';

import LottieView from 'lottie-react-native';

export default class LottiesIcon extends React.Component {
  constructor(props) {
    super(props);
  }
  componentDidMount() {
    this.animation.play();
    // Or set a specific startFrame and endFrame with:
    this.animation.play(30, 120);
    console.log(this.props.focused )
  }
  render() {
    return (
      <LottieView
        ref={animation => {
          this.animation = animation;
        }}
        imageAssetsFolder={['/assets/lottie/XXXX','/assets/Lottie/XXXX']}
        source={this.props.focused ? require('../../assets/Lottie/XXXX.json'): require('../../assets/Lottie/XXXX.json')}
      />
    );
  }
}

https://ithelp.ithome.com.tw/upload/images/20200929/20104220ArFjBkXdDf.png

import React from 'react';
import {Button, Text, View, Image} from 'react-native';
import LottieView from 'lottie-react-native';
export default class LottiesIcon_Seed extends React.Component {
  componentDidMount() {
    this.animation.play();
    // Or set a specific startFrame and endFrame with:
    // this.animation.play(30, 120);
  }
  render() {
    return (
      <LottieView
        ref={animation => {
          this.animation = animation;
        }}
        autoPlay={true}
        imageAssetsFolder={'Lottie/XXXX'}
        source={require('../../Lottie/XXXX.json')}
      />
    );
  }
}

https://ithelp.ithome.com.tw/upload/images/20200929/20104220z70g5JuhlX.png

 <Tab.Navigator
        screenOptions={({ route }) => ({
          tabBarIcon: ({ focused, tintColor, color, size }) => {
            if (route.name === 'MyTeam') {
              return <LottiesIcon focused={focused} />;
            }}} />

上一篇
[Day:14] 設計師:我該給你SVG還是PNG ?(눈‸눈)
下一篇
[Day:16] 無盡路由深淵 ||Φ|(|´|Д|`|)|Φ||react-navigation
系列文
ReactNative 懶人開發之路,薪水小偷練成日記(X31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言