為什麼人家的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';
看看這個可愛的小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')}
/>
);
}
}
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')}
/>
);
}
}
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, tintColor, color, size }) => {
if (route.name === 'MyTeam') {
return <LottiesIcon focused={focused} />;
}}} />