【发布时间】:2017-10-30 16:15:16
【问题描述】:
我目前在 react-native 中编写了一个新闻阅读器应用程序,并希望将文章的第一个字母设置为首字母,如下所示:
我第一次尝试使用嵌套文本方法。代码附在下面。这是我目前的结果:
渲染函数中的代码:
<View style={styles.container}>
<Text style={styles.text}>
<Text style={styles.initial}>W</Text>
<Text>
elcome to React Native! To get started, edit index.android.js To get started, edit index.android.js To get started, edit index.android.js
</Text>
</Text>
</View>
我的样式表:
const fontSize = 14;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF',
},
initial: {
fontSize: fontSize * 2,
},
text: {
fontSize: fontSize,
color: '#333333',
},
});
我的问题: 如何设置第一个字符的样式以获得漂亮的首字母?
环境
- 反应:16.0.0-alpha.6
- 反应原生:0.44.2
- 模拟 Nexus 5 上的 Android 6.0
【问题讨论】:
标签: text font-size react-native