Xcode - 从iPhone到iPad大小的缩放字体 [英] Xcode - Scale Font from iPhone to iPad size

查看:223
本文介绍了Xcode - 从iPhone到iPad大小的缩放字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作类似体育应用的内容,其中包含记分牌。我在故事板中创建了一个View,并在视图中拖动了一些UILabel。然后我将约束添加到标签。

I'm trying to create something like a sports app, which contains a scoreboard. I created a View in my storyboard and dragged some UILabels inside the view. Then I added the constraints to the labels.

现在,当我在iPhone上运行应用程序时,屏幕看起来不错。所有字体和标签都有合适的尺寸。但在iPad上看起来像这样:

Now when I run the app on an iPhone the screen looks nice. All fonts and labels have the right size. But on the iPad is looks something like this:

但它应该如下所示:

我该怎么办?扩大字体大小和标签,使其在iPad上完美呈现?

How can I scale up the font size and the labels so it looks perfectly on the iPad?

谢谢

推荐答案

您可以使用大小类。选择要缩放的标签,然后在工具面板上单击字体标签旁边的小+按钮。在下拉列表中选择常规宽度>常规高度。然后在新出现的字体设置中选择更大的字体大小:

You can use size classes. Select the label you want to scale, then on the Utilities panel click the tiny '+' button near the "Font" label. In dropdown list select "regular width" > "regular height". And then in newly appeared Font setting select a bigger font size:

如果您没有使用大小类,那么您必须更改代码中的字体大小(使用 UI_USER_INTERFACE_IDIOM()宏来确定您是在iPhone还是iPad上运行),或者只是创建不同的故事板iPad界面(将新的故事板添加到项目中,然后在您的应用程序的plist中添加主故事板文件基本名称(iPad)键,并将新故事板的名称(不带扩展名)作为值)

If you're not using size classes then you have to either change font size in code (use UI_USER_INTERFACE_IDIOM() macros to determine whether you running on iPhone or iPad), or simply create different storyboard for the iPad interface (add new storyboard to the project and then in your app's plist add "Main storyboard file base name (iPad)" key with your new storyboard's name (without extension) as value)

这篇关于Xcode - 从iPhone到iPad大小的缩放字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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