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.
Related
I have created a Launch screen.I have added one image & label on it.Now for diffrent screen size devices i am able to increase the size of image with autolayout.But i am not able to increase the font size of label.I can't use custom class of label for storyboard.So is there any way with i am able to increase font size for multiple devices on launch screen.
Option for different font size for different size class is available in storyboard.
NO. It is not possible to implement custom font for LaunchScreen, since LaunchScreen will be loaded before your custom fonts load. Better create different images with the text you want to display.
Well it is not possible you can write code for a launchScreen and handle some logic as for a conventional ViewController. Also you cannot use a custom class of label or extension. You can use only Auto-Layout and size classes. The detailed explanation is in the link
I've been trying to set different font sizes for different iPhone sizes. I researched a lot about this but couldn't find the proper way of doing it. All I found is how to change uilabel text size in different iPhones which shows how to change the font size based on hard coded values that too programmatically. I'm looking for changing the font size using storyboard i.e adaptive layout. Another popular answer I found was to add wC hAny in storyboard. But, this can only be used to set the different font size for an iPad and iPhone(not for different iPhone sizes). Any help would be appreciated.
One way to do this is to set the minimum font size for the label. Then set your constraints so when the labels get squished in a tighter area the font will shrink to fit on the screen.
If the text of a label in a universal storyboard is too long to fit some resolutions, how do I accommodate it?
Storyboard View
iPhone 6 Emulator
I'm not sure if there is a proper way to go about this according to the guidelines, but I would assume I would either text wrap onto multiple lines or adjust the font size automatically.
Here is a simple gif, which can help you to understand it better.
You can do either. First set the constraints so that the UILabel does not go past the edge of the screen. Then you have two options. Either set the minimum font size of set the number of lines to 0 (or both).
All of these settings can be set in storyboard.
Edit to following your comment
Constraints are usually set in the storyboard and dictate how a view is drawn based on the device you are using. It's a large and critical subject and Ray Wenderlich has a very good two part tutorial on it.
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?
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.