我有一個視圖,其中包含一個影像,另一個視圖覆寫它。我希望使用 captureRef 來保存帶有疊加層的影像,但是當我嘗試這個 Expo Go 時,它會崩潰而不會留下任何日志或錯誤訊息。有什么可能導致這種情況嗎?
//I have a button that calls this. This is what crashes the app
const savePicture = async () => {
const result = await captureRef(savedPicture, {
result: 'tmpfile',
})
}
// if photoData isn't undefined we render this
<View style={styles.container} ref={savedPicture}>
<Image source={{ uri: photoData.uri }} style={styles.camera}/>
<View style={styles.overlay}>
<View style={styles.shape}/>
</View>
</View>
我正在嘗試做的類似于此https://kyleclutter.medium.com/react-native-adding-overlay-date-stamp-to-photo-7c7299327004
captureRef 的檔案:https ://docs.expo.dev/versions/latest/sdk/captureRef/
uj5u.com熱心網友回復:
好的,經過數小時的嘗試后,我發現裁判的視圖必須具有背景顏色。沒有透明度。我不知道這是否是專門針對 Expo 或 captureRef 的錯誤。可能是新版本的東西,因為據報道舊版本不會發生這種情況。
希望這可以幫助你們中的一些沮喪的開發人員。
固定代碼:
<View style={[styles.container, {backgroundColor: 'black'}]} ref={savedPicture}>
<Image source={{ uri: photoData.uri }} style={styles.camera}/>
<View style={styles.overlay}>
<View style={styles.shape}/>
</View>
</View>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/532094.html
