xcode 根据每个 iPhone 大小更改字体大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39523476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:15:41  来源:igfitidea点击:

changing the font size according to each iPhone size

iosxcodefont-sizexcode8ios-autolayout

提问by aznelite89

is there any way to changing/auto resizing the font size according to the different iPhone screen as when i change the font size, the font size applied to other phone size as well which is too big.

有什么方法可以根据不同的 iPhone 屏幕更改/自动调整字体大小,因为当我更改字体大小时,应用于其他手机大小的字体大小也太大了。

My Current Phone size is iPhone 6s plus (5.5 inch) enter image description here

我当前的手机尺寸是 iPhone 6s plus(5.5 英寸) 在此处输入图片说明

enter image description here

在此处输入图片说明

采纳答案by Ganesh Amrule

Please use size classes to support different font size for different screens. Here is good tutorial about using size classes. adaptive-layout-tutorial

请使用大小类来支持不同屏幕的不同字体大小。这是关于使用大小类的好教程。自适应布局教程

回答by Hamiz Ahmed

I ran in to a similar issue. I suggest to use this library: https://github.com/hamiz-ahmed/SizeOptimizedLabel

我遇到了类似的问题。我建议使用这个库:https: //github.com/hamiz-ahmed/SizeOptimizedLabel

Specify the initial screen and font size. The font gets optimized automatically according to different screen sizes.

指定初始屏幕和字体大小。字体会根据不同的屏幕尺寸自动优化。

回答by lee5783

I faced this issue few months ago. There is no way to do it on storyboard for now.

几个月前我遇到了这个问题。目前没有办法在故事板上做到这一点。

You can do it by code by detect screen size or device type and set font size for each device. You can use this lib to do that

您可以通过检测屏幕大小或设备类型并为每个设备设置字体大小来通过代码来完成。你可以使用这个库来做到这一点

https://github.com/sebyddd/SDVersion

https://github.com/sebyddd/SDVersion