Question

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.

Basically:

  • UIImage.FromBundle("Images/close.png"), this will work: it loads the close@2x.png and scales it down
  • UIImage.FromFile("Images/close.png"), this doesn't work
  • UIImage.FromFile("Images/close@2x.png"), this loads the image but i'm not sure it will do the expected things (ie: downscale it on non retina device and use it correctly on retina device)

Any hint? I thought that iOS7 was handling this automatically.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top