我通过require
引用图像,我想从精灵图像中裁剪图标。
const sprite = require('./sprite.png')
const crop = {left: 10, top: 50, width: 20, height: 40}
export const cartLogo = sprite({crop})
// How do I apply the crop to the sprite?
then
<Image source={cartLogo}/>
我看到了使用
{uri: 'url-to-image', crop: {left: 10, top: 50, width: 20, height: 40}}
in here时如何在本机图像中裁剪图像。 require
怎么做? 最佳答案
我知道require('./ sprite.png')很快就会贬值。
因此,最好的方法是使用
image : {uri: ..., crop: {left: 10, top: 50, width: 20, height: 40}}
您还可以关注my post here.
让我们知道您是否成功