Created
May 27, 2017 09:00
-
-
Save jinwei233/fad329664df56a07c91638b1667f0185 to your computer and use it in GitHub Desktop.
多行文本垂直居中,前置 icon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { | |
View, | |
Text, | |
StyleSheet, | |
AsyncStorage, | |
Platform, | |
} from 'react-native'; | |
class Item extends Component { | |
render() { | |
return ( | |
<View style={styles.item}> | |
<View style={styles.body}> | |
<View style={styles.bodyIn}> | |
<Text style={styles.name} numberOfLines={2}>{this.props.text}</Text> | |
<View style={styles.icon}></View> | |
</View> | |
</View> | |
</View> | |
) | |
} | |
} | |
class Block extends Component { | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Item text=" 中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文" /> | |
<Item text=" 中文中文中文中文中文" /> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
}, | |
item: { | |
marginTop: 80, | |
height: 135, | |
backgroundColor: '#ccc', | |
}, | |
body: { | |
height: 50, | |
backgroundColor: '#999', | |
justifyContent: 'center', | |
overflow: 'hidden', | |
}, | |
bodyIn: { | |
}, | |
icon: { | |
width: 12, | |
height: 12, | |
backgroundColor: 'green', | |
position: 'absolute', | |
left: 8, | |
top: 5, | |
}, | |
name: { | |
lineHeight: 20, | |
backgroundColor: 'red', | |
} | |
}); | |
export default Block; |
Author
jinwei233
commented
May 27, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment