Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclusion paths on a UILabel's TextContainer

Is it possible to set exclusion paths on a UILabel? The apple documentation states that UILabel is now built upon TextKit but a UILabel does not seem to expose a textContainer property.

I am looking to implement a tableview cell which includes multiple labels and a roux badge which the labels should not overlap (shown below).

enter image description here

If it is not possible with a UILabel how can I make a TextView act like a UILabel (no scroll, selection etc) and size it to fit it's contents?

like image 556
bencallis Avatar asked Mar 22 '14 17:03

bencallis


1 Answers

It is correct that UILabel does not expose the TextKit stack, so you can't set an exclusion path.

However, you don't really need UILabel; it is easy to draw directly with TextKit into a rectangular graphics context, and now you can set an exclusion path (because you are drawing with TextKit). To draw with TextKit, just build the text kit "stack", customizing in any way you like, and then, when it's time to draw, call the layout manager's drawBackgroundForGlyphRange:... and drawGlyphsForGlyphRange:....

like image 190
matt Avatar answered Sep 28 '22 04:09

matt