Font Size on Universal Storyboard

Font size on universal storyboard

When you're using universal storyboards, each text-displaying control in a storyboard will now have a small + icon to the left of the font setting in the Attributes Inspector. If you click it, it will allow you to set different values for different size classes.Sample Image

From @OrangeDog comment

iPhone: wC hA | iPad: wR hA

Different font size for different devices in Xcode 6

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. At the bottom of the Storyboard design window you'll see the (default) 'w Any h Any' button. 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. You have full control.

For your font related question, you access the size-class control through the '+' sign I mentioned above.

This is a good explanation and tutorial:
Wenderlich size classes

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.

How do I handle long text labels on a universal storyboard?

Here is a simple gif, which can help you to understand it better.

Sample Image

How do I make text labels scale the font size with different Apple product screens?

You can actually do it in your Storyboard.

1, open File Inspector tab(First tab) on your storyboard, set both Use auto layout and Use size classes check.

2, Then you can go to your label attribute(Forth tab), you will notice that there is a "+" beside, click it to add.

3, Choose the screen size u want like, can refer "Adaptivity and Layout" and then select your font size.

Answer refer to THIS LINK, you can also take a look

Swift 4 iOS - Completely override system font without compromising storyboard font size

The solution I approached it's similar to the #2 solution but it renders the font on the storyboard too.

We created some classes that extend the default UIViews, for example for UILabel and UIButton. You can do something like this:

@IBDesignable
public class CustomUILabel: UILabel {

public override func awakeFromNib() {
super.awakeFromNib()
configureLabel()
}

public override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
configureLabel()
}

func configureLabel() {
font = UIFont(name: "MyCustomFont", size: self.font.pointSize)
}

}

@IBDesignable
public class CustomUIButton: UIButton {

public override func awakeFromNib() {
super.awakeFromNib()
configureLabel()
}

public override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
configureLabel()
}

func configureLabel() {
titleLabel?.font = UIFont(name: "MyCustomFont", size: self.titleLabel!.font.pointSize)
}

}

Then in the storyboard we set in the Identity Inspector that class as Custom Class to each component that had to change the font.

It is not the most clean solution, but at least if you change the MyCustomFont font in the whole application you can just change it by code in one single shot.



Related Topics



Leave a reply



Submit