Skip to content

Instantly share code, notes, and snippets.

@jinwei233
Created May 27, 2017 09:00
Show Gist options
  • Save jinwei233/fad329664df56a07c91638b1667f0185 to your computer and use it in GitHub Desktop.
Save jinwei233/fad329664df56a07c91638b1667f0185 to your computer and use it in GitHub Desktop.
多行文本垂直居中,前置 icon
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;
@jinwei233
Copy link
Author

qq20170527-170040 2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment