iphone - Swift in iOS: Resizing UIImage for Portrait or Landscape -


i trying create app allows users select pictures photo library on iphone , make uiimage view more responsive either portrait or landscape view of screen.

in view controller, have uiimage: uiimage in viewcontroller

then set 4 constraints on constraints

however, when select image photo library, size of picture not responsive portrait or landscape. size of picture seems smaller width (380) & height (419) of uiimage. landscape view

the relevant code uiimagepickercontroller is:

   self.pickedimage.image = image     self.pickedimage.contentmode = .scaleaspectfit 

so wondering how make size of picture responsive screen (landscape/portrait). thanks

it doing ordered to: top spacing of 16 pixels navigation bar , bottom spacing of 99 pixels toolbar. uiimageview wider image (you can check changing background color). if make margins smaller, see image increase in size.


Comments