문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top