How proportionally the size of the iphone-based image is used

Say I have a large image (400wx700h) pixels. I want this image to be focused on the iphone and occupy 1/4 of the display area. It doesn’t matter whether iphone 4 or iphone 6+, I still want this image to be centered and occupy only 1/4 of the display area. Also, I want to create this in a storyboard and use restrictions without encoding. I know how to center the image, but not sure about 1/4. Can someone guide me?

Thanks Bourne

+1
source share
2 answers

Create constraints for equal width and height with a super view and set the factor in each constraint to 0.25

0
source
  • Use UIImageView to host your UIImage.
  • Set imageView.contentMode to ScaleToFit enter image description here
  • Use width restrictions of equal and equal heights from the image in the form of a viewController. enter image description here
  • Use the factor (4 with the inverse factor) on the constraints to adjust the size as you wish. enter image description here
0
source

All Articles