问题描述
我正在使用iOS7在模拟器中进行测试。我的所有资产都是视网膜,只有@ 2x名称。我对UIImage.FromFile有一种非常奇怪的行为。
请注意,模拟器iPad和模拟器iPad Retina的行为相同。
I am testing in the simulator with iOS7. All my assets are retina only with the @2x name. I have a very weird behaviour with UIImage.FromFile.Please note that the behaviour is the same with simulator iPad and simulator iPad Retina.
基本上:
- UIImage.FromBundle(Images / close.png),这将有效:它加载[email protected]并将其缩小
- UIImage .FromFile(Images / close.png),这不起作用
- UIImage.FromFile(Images/[email protected]),这会加载图像,但是我我不确定它会做预期的事情(即:在非视网膜设备上缩小它并在视网膜设备上正确使用它)
任何暗示?我认为iOS7自动处理这个问题。
Any hint? I thought that iOS7 was handling this automatically.
推荐答案
根据Xamarin文档 - (查看文章末尾) - 使用FromFile类似于使用FromBundle ,除了你必须传递整个文件路径,包括文件后缀。
,所以这意味着如果你使用 FromFile
,你应该添加 @ 2x
后缀到最后。
According to the Xamarin documentation - Working with Images (look in the end of the article) - Using FromFile is similar to using FromBundle, except that you have to pass the entire file path, including file suffix.
, so it means that if you are using FromFile
you should add @2x
suffix to the end.
这篇关于MonoTouch UIImage.FromFile不加载视网膜资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!