5

I want to make an app, where font size increase or decrease according to font size maintained in iOS in Settings. If you change font size of your iOS from settings, whatsapp font size displayed accordingly, I want same functionality.

XLE_22
  • 5,124
  • 3
  • 21
  • 72
Tejinder
  • 1,507
  • 19
  • 22
  • Can use notification to let all controllers through out the app when Font changes then loop through super view and change font as per the size you set in settings. Also you need to write same code in viewDidiAppear, so that if any screen not loaded can also set the required font size. Hope it make sense. – Janmenjaya Sep 23 '16 at 03:37

3 Answers3

2

The iOS functionality you're looking for is the Dynamic Type that only works for text with implemented text styles.

Basically, you must :

  • Use the text styles but beware, their availability depends on your iOS version.enter image description here
  • Tick the adjustsFontForContentSizeCategory property (since iOS 10) in your interface builder or implement it in code so as to tell the system to handle automatically the Dynamic Type for the object it belongs to (text styles must be used of course).
  • Adapt all your constraints to the different sizes your app may encounter.

You can also follow the notifications related to the Dynamic Typeevents as indicated below :enter image description here Everything is well explained in this WWDC video detailed summary where all the contents and their video timelapses are indicated to reach rapidly the information.

There's also the possibility of adapting the graphical elements size as well with a Dynamic Type implementation.

XLE_22
  • 5,124
  • 3
  • 21
  • 72
1

All you have to do if to use Dynamic Type for your labels. This means not to set it explicitly but to use styles like Header 1 or caption. This styles are depends on user setting in Accessibility and will change automatically. https://www.raywenderlich.com/77092/text-kit-tutorial-swift

Traveler
  • 191
  • 1
  • 10
  • Can you please elaborate you answer in details? – Tejinder Sep 23 '16 at 03:34
  • what kind of details? Select you label/button, set font style to, for example, `Body` or `Footnote`. Thats all you need to do, thanks to Text Kit and Apple – Traveler Sep 23 '16 at 03:38
1

You can use system default sizes for Texts, like,

self.label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];

Please find documentation here.

For other components you can use like labelFontSize() and many more,

+ (CGFloat)labelFontSize;//Returns the standard font size used for labels.
+ (CGFloat)buttonFontSize;//Returns the standard font size used for buttons.
+ (CGFloat)smallSystemFontSize;//Returns the size of the standard small system font.
+ (CGFloat)systemFontSize;//Returns the size of the standard system font.
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256