【发布时间】:2022-01-01 18:37:24
【问题描述】:
获取本地图像不加载的问题,只是在 Ios 中显示为空白
<Image source={ImagePath.headerBgImage} style={{ width: "100%" }} />;
【问题讨论】:
标签: react-native image ios14
获取本地图像不加载的问题,只是在 Ios 中显示为空白
<Image source={ImagePath.headerBgImage} style={{ width: "100%" }} />;
【问题讨论】:
标签: react-native image ios14
如果我理解正确,_currentFrame 应该是动画图像, 所以如果是静止图像,我们可以使用 UIImage 实现 处理图像渲染
react-native/Libraries/Image/RCTUIImageViewAnimated.m 或在 Pod 中 React- RCTImage>RCTUIImageViewAnimated.m
1c634a9 中的第 283 到 289 行
- (void)displayLayer:(CALayer *)layer
{
if (_currentFrame) {
layer.contentsScale = self.animatedImageScale;
layer.contents = (__bridge id)_currentFrame.CGImage;
}
}
将上面的代码替换为
if (_currentFrame) {
layer.contentsScale = self.animatedImageScale;
layer.contents = (__bridge id)_currentFrame.CGImage;
} else {
[super displayLayer:layer];
}
【讨论】:
你应该去这个文件:
node_modules > react-native > 库 > 图片 > RCTUIImageViewAnimated.m
然后搜索词 if (_currentFrame) 然后找到后添加 else 像这样:
if (_currentFrame) {
layer.contentsScale = self.animatedImageScale;
layer.contents = (__bridge id)_currentFrame.CGImage;
} else {
[super displayLayer:layer];
}
有关更多信息,请参阅link
【讨论】: