[英]How to apply expo react-native custom font to the entire container
[英]Custom font in React-Native Button
如何為 ReactNative 按鈕使用自定義 FontFamily? 這是按鈕:
<Button
title="ACCEDI"
color={"#008800"}
marginVertial={10}
fontFamily={Fonts.Montserrat}
/>
但這不起作用,fontFamily 沒有改變。 我該如何改變它?
請嘗試將其放入樣式屬性中:
textStyle={{fontFamily: Fonts.Montserrat}}
要么
titleStyle={{fontFamily: Fonts.Montserrat}}
以下是有用的鏈接:
https://medium.com/react-native-training/react-native-custom-fonts-ccc9aacf9e5e
https://github.com/react-native-training/react-native-elements/issues/977
嘗試使用此鏈接作為React Native 中的參考自定義字體
編輯 package.json 中的字體文件夾 src 並嘗試此鏈接。
我不認為你可以設置字體系列。 查看按鈕的源代碼。 ( https://github.com/facebook/react-native/blob/master/Libraries/Components/Button.js )。 他們沒有公開任何文本樣式的道具。
const {
accessibilityLabel,
color,
onPress,
touchSoundDisabled,
title,
hasTVPreferredFocus,
nextFocusDown,
nextFocusForward,
nextFocusLeft,
nextFocusRight,
nextFocusUp,
disabled,
testID,
} = this.props;
但是,您可以創建一個 TouchableWithNativeFeedback 並添加一個 Text 組件並提供您喜歡的樣式。
在字體系列中,您只需輸入字體名稱
fontfamily:'your-font-family'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.