you just have to give the your UIImageview size of your UIView and than set its ContentMode to AspectFit like these...i hope it helps..
imgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[imgView setContentMode:UIViewContentModeScaleAspectFit];
[self.view addSubview:imgView];
First you need to switch to different size classes for iPhone and iPad
add an imageView in Size Class any any so that it is available in any size classes
use width compact and height regular Size Class for iPhone
use width regular and height regular for iPad
In both size classes add constraints leading, trailing, top, bottom .
These constraints are for background image. For others you will have to change it as per your requirement.
I hope you already have different images for iPhone and iPad including retina images.
Set size class with respect to device and oritentation
You can take help to change size classes from the following link Size class base on different devices How change size classes
Set constraints for leading, trailing, top and bottom constraint you can also set height and width constraints based on your requirement.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.