4
votes

In Xcode, I use a fixed UILabel with font System, set the text in IB and set the size to fit exactly by pressing Command=

If I run this on an iPad 2 or iPad simulator (non retina), it displays OK. If I run this on an iPad 3 or iPad simulator (retina), it sometimes cuts off the text. Example of text cut off: "Min." is shown as "M .."

After some searching, I found this is caused by the fact that the system font is different: Helvetica on non retina iPad. Helvetica Neue on retina iPad. Therefore the labels seem Ok in design time, but are cut off on retina displays. Helvetica Neue seems marginally wider. If I hardcode the font to Helvetica Neue in IB and press Command-=, the size is adjusted 1 pixel to fit the font.

It seems that IB in Xcode is using Helvetica. Can I switch this to Helvetica Neue somewhere? I would prefer switching the font used in Xcode instead of hard-coding all my fonts to Helvetica Neue.

2

2 Answers

2
votes

Your instinct is right that you don't want to hard code a particular font, since further changes to the system font will leave your app looking outdated or awkward. To avoid this, use Autolayout (constraint-based layout) to make your labels fit the text dynamically.

See the 2013 WWDC videos, specifically Building User Interfaces for iOS7, for a discussion of updates to the type system and Taking Control of Auto Layout in Xcode 5 for a discussion of implementinglayout changes.

1
votes

The Question you are asking is already answered here:Set the default font style, color, and size for an xcode project. Here is the WWDC session video which is quoted in that answer, and tells how to customize the default UI:https://developer.apple.com/videos/wwdc/2012/?id=216