ios - MonoTouch UIImage.FromFile 不加载视网膜 Assets

标签 ios ios7 xamarin.ios xamarin

我正在使用 iOS7 的模拟器中进行测试。我所有的 Assets 都只有@2x 名称的视网膜。我对 UIImage.FromFile 有一个非常奇怪的行为。 请注意,该行为与模拟器 iPad 和模拟器 iPad Retina 相同。

基本上:

  • UIImage.FromBundle("Images/close.png"),这将起作用:它加载 close@2x.png 并将其缩小
  • UIImage.FromFile("Images/close.png"), 这个不行
  • UIImage.FromFile("Images/close@2x.png"),这会加载图像,但我不确定它会做预期的事情(即:在非视网膜设备上缩小它并在视网膜设备上正确使用它)

有什么提示吗?我以为 iOS7 会自动处理这个问题。

最佳答案

根据 Xamarin 文档 - Working with Images (看文末) - 使用FromFile和使用FromBundle类似,只是你必须传递整个文件路径,包括文件后缀。,所以这意味着如果你使用FromFile 你应该在最后添加 @2x 后缀。

关于ios - MonoTouch UIImage.FromFile 不加载视网膜 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23102276/

相关文章:

ios - CALayer subLayer 边界舍入误差?

ios - 无法在 Xcode 中以编程方式创建 map (Big Nerd Ranch IOS 编程 : chapter 6 p97)

iphone - UIView 绘制时的背景色

ios - 在 uiimageview 上方绘制和移动图像 - Swift

ios - 将静态 TableView 与 UIViewController 合并

ios - 如何解决 ios 7 中 ui 标签栏的奇怪行为

ios7 presenting view controller 呈现时不旋转,导致状态栏消失

uiviewcontroller - Autolayout 模棱两可的WTF! UIViewController 的 ___LayoutGuide 属性不明确

c# - 简单的 Segue 在 Xamarin 中不起作用

c# - 使用自动布局约束时,Syncfusion SfRangeSlider slider 和标签未正确对齐