Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rn animated 样式写法有问题 #35

Open
MAYDAY1993 opened this issue Nov 6, 2017 · 1 comment
Open

rn animated 样式写法有问题 #35

MAYDAY1993 opened this issue Nov 6, 2017 · 1 comment

Comments

@MAYDAY1993
Copy link
Owner

import React, {Component} from 'react';
import {View, Text,Animated,Easing,StyleSheet} from 'react-native';
import {Actions} from 'react-native-router-flux';

export default class PageOne extends Component {
  constructor(props){
    super(props);
    this.state={
      fadeInOpacity: new Animated.Value(0)
    }
  }
  componentDidMount(){
    Animated.timing(this.state.fadeInOpacity,{
      toValue:1,
      duration:2500,
      easing:Easing.linear
    }).start();
  }
  render(){
    return (
      <View style={{margin:128}}>
        <Text>this is pagethree</Text>
        <Text onPress={() => Actions.pop()}>back</Text>
        <Animated.View style={[styles.demo,{
          opacity:this.state.fadeInOpacity
          }]} >
          <Text style={styles.text} >fade in....</Text>
        </Animated.View>
        
      </View>
    )
  }
}

var styles=StyleSheet.create({
  demo:{
    flex:1,
    alignItems:'center',
    justifyContent:'center',
    backgroundColor:'white'
  },
  text:{
    fontSize:30
  }
})

把 styles改成 就可以了 :

<Animated.View style={{
         opacity:this.state.fadeInOpacity
         }} >

多个样式就是写成数组形式吧 求教

@MAYDAY1993
Copy link
Owner Author

解决啦 外层要加flex=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant