문제

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?

도움이 되었습니까?

해결책

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:....

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top