3

I want to use the same text on different devices. I am using the universal storyboard but I can't find any constraints for the font size. I know that you can use different text fields on different devices with the new layout but then I need to add some logic in the code. I want to use same text field.

hidayat
  • 9,493
  • 13
  • 51
  • 66
  • I dont think this works at the moment. http://stackoverflow.com/questions/26166737/custom-font-sizing-in-xcode6-size-classes-not-working-properly-w-custom-fonts – SashaZ Aug 05 '15 at 08:29

1 Answers1

15

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.

Community
  • 1
  • 1
Magnas
  • 3,832
  • 5
  • 33
  • 48
  • 5
    Please edit your answer to also include some information about what size classes are and maybe a helpful link where they can find some helpful reading material about them – Shamas S Mar 08 '15 at 09:31
  • Does it possible to set the font based on the iPhone size in storyboard. I have tried with Auto shrink option, but the app is displaying the same font size for all devices(4', 4.5',5'). Can you please help me how to achieve. – Ganesh May 16 '17 at 12:36
  • @Ganesh - Follow the link in my edited answer and see the answer by user3069232. – Magnas May 16 '17 at 14:31
  • I have checked your edited answer. Still I could not found the solution for differentiate the text size between iPhone models. Programatically can achieve. But I want do it with storyboard. Please help me if you have any idea. – Ganesh May 17 '17 at 09:55
  • I think it can only be done programmatically. I have never seen a way to do what you want with storyboards. Sorry. – Magnas May 17 '17 at 11:21