I have a UILabel
with the string \'LA\'. I also have a CATextLayer
with the same characters in an NSAttributedString
assigned to its
Well Core Text
is really different when compared to drawing strings using UIKit, probably because it comes from Core Foundation
and not AppKit
or UIKit
. I do understand your requirements to use a label for doing the metrics hard job on a string. The only solution for me is to match the kerning of UILabel
in the attributed string, unfortunately I don't know the exact value but you can use this property to change that value kCTKernAttributeName
. You should pay attention also for the interline that could be not the same.
Forcing that value to the matching kerning you could have the correct behavior. If you want the opposite (match CT kerning) you should do some math an later apply to the label a UIEdgeInset
to math the correct label.
Hope this helps.