Search code examples
iosxcodeautolayoutnslayoutconstraintaspect-ratio

Xcode proper Auto Layout Constraints missing for circular profile picture across different devices


  • I want to know what constraints should be added to make that User Image View stay the same ratio and also probably the same size across different iOS devices.

  • This is the Storyboard view of my profile image. enter image description here

  • Below is the document outline hierarchy where Button and User Image View are put in a separate view. (I am not sure if this is really needed or not.) enter image description here

  • Attributes Inspector of the User Image View. enter image description here

  • Sizes Inspector of the User Image View. enter image description here

  • This is supposed to be a circle. enter image description here


Solution

  • First, You should remove all the constraints and add the constraint VERTICAL SPACING, HORIZONTAL SPACING, WIDTH(Fixed), HEIGHT(Fixed). It should look like below. It will give you fixed sized ImageView on all the devices.

    enter image description here