TechChain
TechChain

Reputation: 8952

Aspect ratio issue with iPad?

I have added a big image in center of screen.I have given following constraints to the image.

I have added a view on top of that image having constrants

I want my view to be on same place as it is on the 5s so it should be same place on image as on iPad. I have made a logic like this

    float aspect_ratio_top=157.0/568.0;
    float aspect_ratio_width=81.0/320.0;

    float constant_top=self.view.frame.size.height*aspect_ratio_top;
    float constant_leading=self.view.frame.size.width*aspect_ratio_width;

    self.nslc_mainFrame_top.constant=constant_top;
    self.nslc_mainFrame_leading.constant=constant_leading;

Here 157.0 is value of constraint from top & 568.0 is iPhone5 height. Here 81.0 is value of constraint from left & 320.0 is iPhone5 width.

This works great upto iPhone6 plus but on iPad width constraint value is not correct.I need to add more value to fit the width constraint.Please tell me the solution ?

Upvotes: 1

Views: 248

Answers (1)

Bhargav B. Bajani
Bhargav B. Bajani

Reputation: 927

u can set equal width to superview and set multiplier (like 0.9 or 0.75) so view(imageView)width will set s per superview. if superview 100 and multiplier is 0.75 then imageView width will 75.

u can also set different multiplier for iPhone & iPad

Upvotes: -1

Related Questions