[英]Custom font in React-Native Button
How can I use a custom FontFamily for a ReactNative Button?如何为 ReactNative 按钮使用自定义 FontFamily? This is the button:
这是按钮:
<Button
title="ACCEDI"
color={"#008800"}
marginVertial={10}
fontFamily={Fonts.Montserrat}
/>
but this is not working, the fontFamily is not changing.但这不起作用,fontFamily 没有改变。 How can i change it?
我该如何改变它?
Try to put it in the style property, please:请尝试将其放入样式属性中:
textStyle={{fontFamily: Fonts.Montserrat}}
OR要么
titleStyle={{fontFamily: Fonts.Montserrat}}
Here are the useful links:以下是有用的链接:
https://medium.com/react-native-training/react-native-custom-fonts-ccc9aacf9e5e https://medium.com/react-native-training/react-native-custom-fonts-ccc9aacf9e5e
https://github.com/react-native-training/react-native-elements/issues/977 https://github.com/react-native-training/react-native-elements/issues/977
Try using this link as a reference custom fonts in react native尝试使用此链接作为React Native 中的参考自定义字体
Edit the font folder src in package.json and try this link.编辑 package.json 中的字体文件夹 src 并尝试此链接。
I don't think you can set font-family.我不认为你可以设置字体系列。 Look at the source code for button.
查看按钮的源代码。 ( https://github.com/facebook/react-native/blob/master/Libraries/Components/Button.js ).
( https://github.com/facebook/react-native/blob/master/Libraries/Components/Button.js )。 They havent exposed any prop for text style.
他们没有公开任何文本样式的道具。
const {
accessibilityLabel,
color,
onPress,
touchSoundDisabled,
title,
hasTVPreferredFocus,
nextFocusDown,
nextFocusForward,
nextFocusLeft,
nextFocusRight,
nextFocusUp,
disabled,
testID,
} = this.props;
You can however create a TouchableWithNativeFeedback and add a Text component and give the styles you like.但是,您可以创建一个 TouchableWithNativeFeedback 并添加一个 Text 组件并提供您喜欢的样式。
in font family you simple put the font name在字体系列中,您只需输入字体名称
fontfamily:'your-font-family'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.