简体   繁体   中英

How to allow images to resize for 4 inch iphone 5

I have an image view and underneath it a 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. 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.

You need to set UIImageView autosizing property:

在此输入图像描述

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. Choose 3,5", and make your views and subviews resizable .This will make it automatically scale your view to fit iPhone 5's screen.

2.OR you can make use of Auto Layout (constraints) with the deployment target of iOS 6+.

Hope this will solve the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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