简体   繁体   English

Xcode 6中不同设备的字体大小不同

[英]Different font size for different devices in 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. 这将允许您为文本选择特定尺寸的东西。

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. 当Apple推出通用故事板时,尺寸等级被添加到iOS 8中,它允许您使用相同的Storyboard文件设计iPad和iPhone。 At the bottom of the Storyboard design window you'll see the (default) 'w Any h Any' button. 在Storyboard设计窗口的底部,您将看到(默认)'w Any h Any'按钮。 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. 这些可用的组合让您可以实现设计,例如仅适用于横向iPhone,或者两种方向的iPad。 You have full control. 你有完全的控制权。

For your font related question, you access the size-class control through the '+' sign I mentioned above. 对于与字体相关的问题,可以通过我上面提到的“+”符号访问size-class控件。

This is a good explanation and tutorial: Wenderlich size classes 这是一个很好的解释和教程: Wenderlich大小类

and in Apple's own words: Apple size classes 用苹果公司自己的话说: 苹果规模等级

EDIT: - If you really want to have different font sizes for different screen sizes, then this answer should help you. 编辑: - 如果你真的想为不同的屏幕尺寸使用不同的字体大小,那么这个答案应该对你有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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