I have a class which loads an image from an Embedded Resource in a referenced MonoTouch library as follows:
UIImage.FromResource (null, "Resources.Items");
If it was UIImage.FromFile ("abc.png");
and I included a file named [email protected]
the retina image would be displayed on a compatible device.
How do I achieve the same, i.e. load a retina image, using UIImage.FromResource (null, "Resources.Items");
I cannot use UIImage.FromFile ("abc.png");
as the resource is in a referenced DLL.
It's easy to detect a retina display. From there you can load the right resource from your assembly. E.g.
UIImage.FromResource (null, (UIScreen.MainScreen.Scale > 1.0)
? "Resources.Items.Retina" : "Resources.Items");
Using this you can name your retina resource as you like, including using the standard @2x
notation if you like it.