What is the value for spacing between lines in a wrapped CATextLayer?

217 Views Asked by At

I am trying to create a CATextLayer with a frame that is the exact size of 3 lines of text + the spacing in between this text. I know that my font size is 12.

The height of the frame should therefore be 12*3 + 2*spaceSize.

I want the number that spaceSize is equal to, I can't find it anywhere.


The font I'm using is Helvetica if that helps.

1

There are 1 best solutions below

0
Arsil On
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString( (CFMutableAttributedStringRef) textLayer.string);
CGSize suggestedSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX), NULL);
CFRelease(framesetter);
CGFloat layerHeight = ceil(suggestedSize.height);
spaceSize = (layerHeight - 36) / 2.0;