我在屏幕中央添加了一个大图像。我对图像给出了以下约束。
我在具有约束的图像上添加了一个视图
我希望我的视图与5s位于同一个位置,因此它应该与iPad上的图像位置相同。 我做了这样的逻辑
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;
这里157.0是top&的约束值。 568.0是iPhone5的高度。 这里81.0是左和右的约束值。 320.0是iPhone5的宽度。
这适用于iPhone6 plus,但iPad宽度约束值不正确。我需要添加更多值以适应宽度约束。请告诉我解决方案?
答案 0 :(得分:-1)
你可以设置与superview相等的宽度并设置乘数(如0.9或0.75),因此view(imageView)宽度将为每个superview设置s。如果superview 100和乘数为0.75,则imageView宽度为75。
你还可以为iPhone和iPhone设置不同的乘数。 iPad