简体   繁体   English

如何让图像为4英寸iphone 5调整大小

[英]How to allow images to resize for 4 inch iphone 5

I have an image view and underneath it a webview. 我有一个图像视图,下面是一个webview。 They have a small vertical distance between them when viewed on a 3.5 inch screen but when I apply retina 4 Form Factor the image view expands (the actual image size is fixed) so that there appears to be a big gap between it and the webview underneath. 当在3.5英寸屏幕上观看时,它们之间的垂直距离很小但是当我应用视网膜4形状因子时,图像视图会扩展(实际图像大小是固定的),因此它与下面的webview之间似乎存在很大差距。 Also there is a gap between the image view and the top of the screen. 图像视图和屏幕顶部之间也存在间隙。 I have experimented with constraints but don't seem to be able to alter things so that it is the webview which expands vertically, leaving a small gap between it and the imageview. 我已经尝试了约束,但似乎无法改变事物,因此它是垂直扩展的webview,在它和imageview之间留下了一个小的差距。

You need to set UIImageView autosizing property: 您需要设置UIImageView autosizing属性:

在此输入图像描述

OR you can set it programatically using 或者您可以使用以编程方式设置它

imageView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

If this doesn't solve your problem, you have two possible solutions for this. 如果这不能解决您的问题,那么您有两种可能的解决方案。 Listed below: 下面列出:

1.In the 'Simulated Metrics' section of UIVIew's attributes inspector, you can choose between 3,5" or 4" sizes. 1.在UIVIew属性检查器的“模拟指标”部分,您可以选择3,5“或4”尺寸。 Choose 3,5", and make your views and subviews resizable .This will make it automatically scale your view to fit iPhone 5's screen. 选择3,5“,并使您的视图和子视图可调整大小。这将使其自动缩放您的视图以适应iPhone 5的屏幕。

2.OR you can make use of Auto Layout (constraints) with the deployment target of iOS 6+. 2.OR您可以使用iOS 6+部署目标的自动布局(约束)。

Hope this will solve the issue. 希望这能解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM