Specify a resource image for UIImageView for all devices

Is there a way I can say for a specific UIImageView:

UIImageView *imageView = <#instantiate#> imageView.image = @"someImageFromImageAsset"; 

and based on the device he renders, he sets the correct image. Obviously, I need to set an image for a specific device, but I'm not sure how you do it.

+5
source share
1 answer

iOS will automatically select the image with the correct size if you just use the image name. Use @ 2x in the image file name to display the retina.

Objective-c

 imageView.image = [UIImage imageNamed: @"someImageName"]; 

Swift

 imageView.image = UIImage(named: "someImageName"); 
+12
source

Source: https://habr.com/ru/post/1204784/


All Articles