问题
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