在Interface Builder中,如何正确调整此图像的大小以使其特定于设备? [英] In Interface Builder, how I do to resize correctly this image to make it device specific?

查看:116
本文介绍了在Interface Builder中,如何正确调整此图像的大小以使其特定于设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自动布局功能,我想知道我是否可以针对不同的屏幕尺寸使用不同的图像尺寸。

I am using the Auto Layout feature, and I would like to know if I can use different image sizes for different screen sizes.

这是我的 Storyboard 文件的样子。

Here's what my Storyboard File looks like.

正如你所看到的,有一个人的形象。如何为每个屏幕尺寸保持图像比例的大小?让我解释一下。

As you can see, there is an image of a guy. How do I keep the size of image proportional for every screen size? Let me explain.

在iPhone 4上这个家伙的形象应该比iPhone 5.5上的小一点。这甚至可能吗?

On an iPhone 4" the guy image should look a little bit smaller than on an iPhone 5.5". Is this even possible?

在iPhone 3.5上图像应该看起来。在iPhone 4上相同的图像看起来应该是稍大一点。在iPhone 4.7上应该看起来更大,依此类推。

On an iPhone 3.5" the image should look small. On an iPhone 4" the same image should look a little bit bigger. On an iPhone 4.7" it should look even bigger, and so on.

设置约束无济于事,

请看下面的图片:

有两个iPhone,两个设备上的图像看起来应该不同。在iPhone 4S上,图像应该看起来更小到在iPhone 6 Plus上很好地适应大灰点这个家伙的形象应该看起来更大,以便最大限度地利用它的屏幕尺寸。

There are two iPhones and the guy image should look different on both the devices. On the iPhone 4S the image should look smaller to fit nicely the big grey dot while on the iPhone 6 Plus the guy image should look definitely bigger to get the most out of its screen size.

有什么方法可以做它?

谢谢你。

推荐答案

所以,你必须首先了解 AutoLayout 尺寸等级的内容。 AutoLayout 基本上可以帮助您放置UI元素。尺寸等级启用您可以控制在不同屏幕尺寸上添加的约束。

So, you have to understand what's AutoLayout and Size Class first. AutoLayout basically helps you place the UI elements. And the Size Class enables you to have the control on the constraints you added on different screen size.

Wha您需要做的是为不同的屏幕设置不同版本的约束。您可以在助理编辑器(右侧面板)中查看选项。他们可以选择申请全尺寸班级或此大小班级。

What you need to do is set different version of constraints for different screens. You can see the options in the assistant editor(right panel). They have you the options to choose apply for "All Size Classes" or "This Size Class".

最好先查看文档和WWDC视频。它有完整的解释: https://developer.apple .com / library / ios / recipes / xcode_help-IB_adaptive_sizes / chapters / EnablingAdaptiveSizeDesign.html

Better you go check the documentation and the WWDC video. It has the complete explanation: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/EnablingAdaptiveSizeDesign.html

这篇关于在Interface Builder中,如何正确调整此图像的大小以使其特定于设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆