正确的图像和字体比例在不同的设备? [英] Correct Image and Font Scale on different Devices?

查看:130
本文介绍了正确的图像和字体比例在不同的设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本和图像的简单视图。我跑iPhone6​​Plus和iPhone5的这个程序。然后我做了两者的屏幕截图,并扩大了iPhone5的屏​​幕截图,使得它从iPhone6​​Plus截图的尺寸相匹配。下面是结果:

I have a simple view with a text and an Image. I ran this app on iPhone6Plus and iPhone5. Then I made a screenshot of both and enlarged the iPhone5 screenshot such that it matches the size of the screenshot from iPhone6Plus. Here is the result:

如可以本身的文本的大小的图像的大小和存在位置是不相同的,但它们应该是看起来不同屏幕上的相同大小的。

As you can se the size of the text the size of the image and there positions are not identical but they should be to look the same on different screen sized.

下面是不同的屏幕运行天气应用程序的例子:

Here is an example of a weather app running on different screens:

正如你所看到的大小和文本和图像的位置是相同的。

As you can see the sizes and the positions of text and image are identical.

图片是从资产目录加载:

The image is loaded from asset catalog:

imageView.image = UIImage(named: "shower3")
self.view.addSubView(imageView)
imageView.center = self.view.center

我只创建了128×128的图像,并把它变成在资产cataloge的@ 1X版本。

I have only created a 128x128 image and put it into the @1x version in the asset cataloge.

让我重新整理这一点。我运行的iPhone5的羯羊应用使ascreenshot和iPhone6​​制作一个屏幕画面。然后,我同时调整截图大小相同。然后,我看到两个字号以及图像尺寸是两个截屏完全相等。这意味着,在每一个设备的字体和图像必须具有不同的尺寸。我该怎么办呢?

Let me rephrase this. I run the wether app on iPhone5 make ascreenshot and iPhone6 make a screenshot. Then I resize both screenshots to the same size. Then I see that both fontsize as well as images dimension are exactly equal on both screenshots. This means that on each device font and image must have different dimensions. How can I do that?

我怎样才能做到这一点的文字和图片对不同屏幕尺寸相同的比例如何?如何在天气应用办呢?

How can I achieve that text and image have identical proportions on different screen sizes? How does the Weather App do it?

推荐答案

你指的是该应用程序不能正确支持多种屏幕尺寸。接口被放大到对6和6加,这就是为什么一切出现相同尺寸运行。

The app you are referring to does not correctly support multiple screen sizes. The interface is scaled up to run on the 6 and 6 plus, which is why everything appears the same size.

看看从你的应用程序的截图 - 在状态​​栏上的6加小得多。这是因为它的应该的占用屏幕上较少的空间。这是高在所有设备上20分。

Look at the screenshots from your app - the status bar is much smaller on the 6 plus. This is because it is supposed to take up less room on the screen. It's 20 points high on all devices.

现在看一下从天气应用程序的截图 - 在状态​​栏的大小相同。因为天气的应用程序不支持多个屏幕尺寸,iOS版只是采用更小的接口和扩展它来填充屏幕。

Now look at the screenshot from the weather app - the status bars are the same size. Because the weather app does not support multiple screen sizes, iOS simply takes the smaller interface and scales it up to fill the screen.

如果你想要达到相同的效果(你应该),然后删除 LaunchScreen.xib 文件,并使用一个启动图像来代替。但是人们,​​因为他们希望有相同的内容,但更大的不买大屏幕打电话。这将只需拿着手机贴近人的脸更便宜来实现。

If you want to achieve the same effect (which you shouldn't) then remove the LaunchScreen.xib file and use a launch image instead. But people don't buy larger phoned screens because they want to have the same content, but bigger. That would be achieved more cheaply by simply holding the phone closer to one's face.

你应该允许更多的内容,以充分利用更大的显示器的同时在屏幕上显示 - 在一个表中的数据更多的行,从一本书的文字,从照片库更多的图像。

You're supposed to take advantage of larger displays by allowing more content to be shown at once on the screen - more rows of data in a table, more text from a book, more images from a photo library.

在一个天气应用程序的情况下,额外的空间,应用于显示每小时预测或东西,而不仅仅是一个相当无用图标描绘气象的类型的大的多行。

In the case of a weather app the extra space should be used to display more rows of an hourly forecast or something, not just a larger version of a fairly useless icon depicting the type of weather.

我怀疑这是唯一的游戏支持,意味着支持更大的屏幕正常是不是已经对应用程序商店提交的要求。支持4英寸的屏幕相当迅速成为强制性的,你应该会推出的6,6加太不久,类似的规则。

I suspect it is only game support that means supporting larger screens properly is not already a requirement for app store submission. Supporting the 4 inch screen became mandatory quite quickly, you should expect a similar rule to be introduced for the 6 and 6 plus before too long.

如果你想有一个特定的元素,始终占据屏幕的宽度,或标签的50%,始终是大小图像相同,则您使用的乘自动布局的限制的。一个自动布局约束的基本结构的:

If you want a specific element to always take up 50% of the width of the screen, or a label to always be the same size as an image, then you use autolayout constraints with multipliers. An autolayout constraint is of the basic structure:

attribute of A = attribute of B + constant * multiplier

大部分的乘数是左为一体,所以你刚才说这是20点到了左边,或什么的,但你可以使用乘法器,以及,说A的时间是宽度的B,乘以2或0.5或任何你喜欢的。

Most of the time the multiplier is left as one, so you're just saying that this is 20 points to the left of that, or whatever, but you can use the multiplier as well, and say that A is the width of B, multiplied by 2 or 0.5 or whatever you like.

这篇关于正确的图像和字体比例在不同的设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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