Currently, my text within a UITextField is truncating at the tail (eg. "Hello, Wor…"). I want the to truncate the text from the leading edge (eg. "…lo, World!").
Currently, my text within a UITextField is truncating at the tail (eg. "Hello, Wor…"). I want the to truncate the text from the leading edge (eg. "…lo, World!").
2
Answers
I believe using
NSMutableParagraphStyle's lineBreakMode
withNSMutableAttributedString
might workThis gives something like this, which is what I think you want:
You just have to update the text attributes (e.g.,
defaultTextAttributes
) with a.paragraphStyle
with alineBreakMode
of.byTruncatingHead
.I would not just replace the
.paragraphStyle
, though. I would fetch it, update itslineBreakMode
, and then update the text attributes with that:Here it is with
.byTruncatingHead
,.byTruncatingMiddle
and.byTruncatingTail
, respectively: