internationalization - iOS - Is hard coding the font / font size bad? -


i'm looking determine how internationalized ios application is, , came across few instances of code this:

[_lbltitle setfont:[uifont fontwithname:@"helveticaneue-bold" size:18.0]]; 

on other platforms, not best practice. example, if wanted decrease font size languages (due text expansion), or if wanted remove bolding (e.g. double byte languages), require code change.

question - best practice ios, , if not alternative?

disclaimer - i'm not @ familiar ios development.

ios not versatile other platforms kind of things, , setting size , font in code common practice, either in class or in external contanst class, or set them in interface builder if using it.

as personal preference, setting fonts in interface builder makes them harder see, prefer have fonts set in class , see them together. then, if change font, rest of them change @ same time, dont have go 1 one elements in xib.

in of solutions you'll have recompile every time change font.

what can think in terms of adapting different languages resizing label text set doing like:

mylabel.minimumfontsize = 8.; mylabel.adjustsfontsizetofitwidth = yes; 

this shrink text down 8 minimun in case doesn't fit.

another practice detect language of phone , setting font there, example:

nsstring * language = [[nslocale preferredlanguages] objectatindex:0]; 

and depending on result language:

[_lbltitle setfont:[uifont fontwithname:@"helveticaneue-bold" size:18.0]]; 

and example another:

[_lbltitle setfont:[uifont fontwithname:@"helveticaneue" size:15.0]]; 

Comments