react native中新增自定義字型
阿新 • • 發佈:2020-12-12
技術標籤:React Native
1、在專案根目錄下,建立資料夾assets/fonts,並且把所需要的字型檔案(.ttf)放進來,
2.ios端
(1)將字型檔案新增到工程目錄中,在工程中的專案檔案下下建立Fonts資料夾,將字型檔案新增進去
(2)在info.plist中新增
<key>UIAppFonts</key>
<array>
<string>Barlow-Regular.ttf</string>
<string>Barlow-Black.ttf</string>
</array>
用法:
fontFamily: "Barlow-Regular"
2.安卓端
直接複製字型到android/app/src/main/assets/fonts目錄下