Autolayout UIButton and UILabel font size according to specific type of the iPhone size[NOT PROGRAMMATICALLY]

与世无争的帅哥 提交于 2019-12-13 06:27:03

问题


I want to set different font size according to the IPhone size (4, 4.7 or 5.5 inch) Here is one of the solution

But I want to ask is there is any way to auto resize UIButton / UILabel font size through interface builder without code? For example, how it works with holding ratio width - height of the UIsmth size? If there is no way to do it as I described - what is the best practice to set font sizes. Should I do it as separate file for each UI element or it s better to do it in the appropriate UI elem subclass? To concrete the question - I'm writing an web app for iPhone portrait only


回答1:


Yeah it's possible you can use sizeClass for it.

Select the viewController wich you want to change the sizeFont, then

HERE:

You select the sizeScreen you want (it will appears blue where you see "any/any" ) and then select the textField, go to the

Attributes inspector

and choose a new size clicking the plus button in the font section :

You will see something like this:

Select and change the size you want, It will work for you



来源:https://stackoverflow.com/questions/38555777/autolayout-uibutton-and-uilabel-font-size-according-to-specific-type-of-the-ipho

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