Search code examples
iosiphoneaspect-ratio

Issue Regarding How to Put Aspect ratio in Ios.


This is What i want to display. As there is super View in that Super there is another View having Height 100 and width 270. i have given constraints like this for inner view (Image) Given Top =5, Leading and Trailing 25 25 and Aspect ratio 320:100(Width of Super View and Height of Inner View), When i add this constraints then size of inner view changes accordingly Means Works Fine. But when I add TextField and Label inside View then Size of label and Textfield Not changes Accordingly Please Specify me what aspect ratio I give To Label and TextField. Please Thank You


Solution

  • Aspect Ratio is used for like as the width increases the height of that particular object also increases with that ratio vice versa case if height increases but giving an object just aspect ratio doesnt mean that the objects dimension will increase/decrease automatically, you have to give other related constraints also to make your object's dimension change as the view's dimension chnage liek for example giving proportional height or width to that object with respect to the view then as the view increases or decreases the dimension of that object will also change.

    enter image description here

    Give equal height to the container enter image description here

    Set the multiplier enter image description here

    The same you do with textField and with bottom label you give Leading Training equal Height and vertical space with the top label and In textfield also the same.

    enter image description here