Xcode 6中不同设备的字体大小不同 [英] Different font size for different devices in Xcode 6

查看:154
本文介绍了Xcode 6中不同设备的字体大小不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不同的设备上使用相同的文字。我正在使用通用故事板,但我找不到任何字体大小的限制。我知道你可以在不同的设备上使用不同的文本字段和新的布局,但我需要在代码中添加一些逻辑。我想使用相同的文本字段。

I want to use the same text on different devices. I am using the universal storyboard but I can't find any constraints for the font size. I know that you can use different text fields on different devices with the new layout but then I need to add some logic in the code. I want to use same text field.

推荐答案

在故事板中选择文本字段。在属性检查器中,您将看到字体选择器左侧的一个小+。这将允许您为文本选择尺寸级别的特定内容。

Select your text field in your storyboard. In the attributes inspector you will see a small '+' to the left of the font selector. This will allow you to choose size-class specific stuff for your text.

当Apple推出通用故事板时,尺寸类已添加到iOS 8中,可让您为iPad和iPad设计iPhone具有相同的Storyboard文件。在Storyboard设计窗口的底部,您将看到(默认)'w Any h Any'按钮。这使您可以访问紧凑和常规大小类的组合。这些可用的组合让您可以实现设计,例如仅适用于横向的iPhone,或者两种方向的iPad。您可以完全控制。

Size classes were added to iOS 8 when Apple introduced Universal Storyboards which let you design for both iPad and iPhone with the same Storyboard file. At the bottom of the Storyboard design window you'll see the (default) 'w Any h Any' button. This gives you access to combinations of the compact and regular size classes. These available combinations let you implement design, say for only the iPhone in landscape, or maybe the iPad in both orientations. You have full control.

对于与字体相关的问题,您可以通过我上面提到的+符号访问尺寸等级控件。

For your font related question, you access the size-class control through the '+' sign I mentioned above.

这是一个很好的解释和教程:
Wenderlich大小班级

This is a good explanation and tutorial: Wenderlich size classes

用Apple自己的话来说:
Apple size classes

and in Apple's own words: Apple size classes

编辑: - 如果你真的想要为不同的屏幕尺寸使用不同的字体大小,然后这个答案可以帮到你。

- If you really want to have different font sizes for different screen sizes, then this answer should help you.

这篇关于Xcode 6中不同设备的字体大小不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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