tags:

views:

793

answers:

2

I would like to use the system font but with a custom leading, but the leading property of a UIFont is readonly. Is there a way to create a system font with a custom leading value?

I am trying to display multiple lines with a UILabel, but the default leading is too narrow. (\n\n is too wide)

If there is no way, then I need to create multiple UILabels but that seems a bit overkill.

+1  A: 

I think you can't do that. UIFont is pretty tightly constrained.

If you have the linebreaks in place yourself then it's fairly trivial to draw the string yourself rather than creating multiple UILabels. You can generating sub-strings using – componentsSeparatedByString: and rendering each of them at your specified leading increments using the UIKit NSString addition: – drawAtPoint:withFont: .

If you need to generate your own wrapping, it's difficult - see this related question.

Roger Nolan
A: 

It could be done by crating a custom category on UIFont and replacing property for lading with custom setter. I am still trying to do this.

Miroslav Kovac
No that could not be done. Besides leading has been deprecated in OS4
Roger Nolan