Xcode - Scale Font from iPhone to iPad size - ios

I'm trying to create something like a sports app, which contains a scoreboard. I created a View in my storyboard and dragged some UILabels inside the view. Then I added the constraints to the labels.
Now when I run the app on an iPhone the screen looks nice. All fonts and labels have the right size. But on the iPad is looks something like this:
But it should look like this:
How can I scale up the font size and the labels so it looks perfectly on the iPad?
Thanks

You can use size classes. Select the label you want to scale, then on the Utilities panel click the tiny '+' button near the "Font" label. In the dropdown list select "regular width" > "regular height". And then in the newly appeared Font setting select a bigger font size:
If you're not using size classes then you have to either change the font size in code (use UI_USER_INTERFACE_IDIOM() macros to determine whether you're running on iPhone or iPad), or simply create a different storyboard for the iPad interface (add a new storyboard to the project and then in your app's Info.plist add the "Main storyboard file base name (iPad)" key with your new storyboard name as a value)

You can specify the font size to be used for each size class. This can be configured in Xcode storyboard editor as described here.

Related

Xcode 9 reset size classes "view as" to show constraints for Any Any

In Xcode 9, I did some UI spot checking using the "view as" feature in Xcode 9 (which was previously in Xcode 8, but is now much more robust).
But now I don't know how to reset this filter*, and now any new constraint I add is created using the size class wC hR. In Xcode 8, I just reset it back to wAny hAny, but this apparently doesn't exist in Xcode 9.
But alas, every new constraint I add is being created with this specific size class:
Instead of:
How can I reset the size class "view as" so that constraints created default to wAny hAny, or "any size class"?
As #matt points out, understandably this isn't a filter per-se, but it still behaves as if it were - filtering the view to only show specific size-class constraints. In Xcode 8 you could reset the view to show constraints for "any any", per "Any" size class missing in Xcode 8.
What you're displaying in your screen shot is not a "size class filter". It's just the displayed dimensions of the view controller's view. It says wChR because those are the size classes for the device type / view size you've selected (you've picked an iPhone in portrait). If you want different dimensions, click the appropriate icons to select the dimensions you want. But nothing is being "filtered" here.
You can never display "Any Any" in the spot shown in your screen shot, because that is not true of any device; no matter what device you select, it has some size classes associated with it, and you will be told what they are.

Set Device-Specific font in Xcode 8.2

i want to set Device-Specific font of UILabel and UIButton using storyboard.
Any one can help me to achieve this?
You can set Label Font Size based on Device using Storyboard. To make it you have follow some steps like below.
First go to the Attributes Inspector panel in storyboard.
Click on this + Symbol of Font Property.
Now set the variations for other devices, Like Compact Width and Compact Height or etc. Set it based on your requirements.
Finally, it will look like,
you can set this property multiple times as per your device specifications like iPhone or iPad etc. You need to define only variations so it will automatic set font size and fonts also.
Hope you get it.

Some help understanding Interface constraints (xcode)

So I have a text view on a view Controller in xcode and i have constraints that keep it in the center of the screen.
But whenever i run the simulator, I only see about half the text view and the other half is off the screen. Am i just not understanding what constraints are used for? Or am I doing something wrong? How would I essentially keep it in the center of the screen no matter what device screen size is being used?
To correctly center your Text View in the center of the ViewControler using AutoLayout constraints, ensure you are following the two essential configurations as below:
Storyboards in versions of Xcode before 7 had to match the screen size of the target device. This clearly isn’t possible with the “one storyboard to rule them all” approach, so with Xcode 7 the storyboard is given an abstract size instead.
The Use Size Classes option, found in the File Inspector, enables this new format for your project; select the storyboard, open the File Inspector and you’ll see the checkbox option as shown in image in link below:
Once you have ensured the setting 'Use Size classes' is selected as above, use Auto Layout constraints to center the Text View in the View Controller as per image in link below:
(If you need then select vertically in container option as well)

Font Size Constraints in XCode6's Interface Builder With Custom Fonts

I'm using XCode6's Interface Builder with different size classes, and want to create a UILabel with a custom font that has a different font size constraint for different screen sizes. According to apple:
https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/ChangingtheFontforaSizeClass.html#//apple_ref/doc/uid/TP40014436-CH12-SW1
you should be able to accomplish this by clicking the + icon next to the font field in the property inspector and choosing different font sizes for the different size classes.
This seems to work perfectly well for me when using system or other fonts that already come embedded in XCode, however, when I use a custom font that I've manually embedded in my project, it no longer respects the constraints and defaults back to the system font and the default font size.
Is this a bug with XCode, or am I doing something wrong?

Changing font sizes with size classes in Interface Builder

The new size classes for auto layout in Xcode is great, but is it also possible to change other things than constraints like font size using size classes?
This is actually quite easy once you find the correct button. There is a small '+' sign to the left of the font select control in the inspector. Press it and choose the size class you want. Then, select different font properties for that size class.

Resources