Enable/Disable font scaling impact by IOS on my application

∥☆過路亽.° 提交于 2020-06-18 02:38:06

问题


I am new to IOS development and working on an application whose font size doesn't get affected by a change in the font size of the phone, which is set by the user, while the font size of other apps installed on my phone gets change. For example if changed from General->Accessibility->Large Text (On) it impacts all the application except mine.

Now as per the requirement of our users it should change the size of our application as well, does anybody know how to enable our disable this font scaling ?

I have searched a lot but could only found solutions for react and flutter only.


回答1:


On each textfield/uilabel there is a flag on the storyboard under the attributes inspector called "Dynamic Type: Automatically Adjusts Font", that needs to be checked.

Also, for the font you need to choose a dynamic font type, in the storyboard these fonts show up under the "Text Styles" section when choosing a font size. When you choose one of those fonts you won't be able to provide a font size as they will pull the fonts dynamically.

In this screenshot I've selected "Caption 1" and checked "Automatically Adjusts Font" which will allow the font to adjust per user settings.

If you are using these settings you should also be using auto-layout wherever possible so the text does not get cut-off on larger sizes.

These settings need to be changed on each uilabel/textfield in your app.

If you are doing this programmatically you need to set the font to a preferred font:

let label = UILabel() label.font = UIFont.preferredFont(forTextStyle: .body)



来源:https://stackoverflow.com/questions/55971292/enable-disable-font-scaling-impact-by-ios-on-my-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!