3

In my UI I have an NSTextField (used as a label). This text field's string value changes dynamically. I'd like to know when its string value is too long to display. I've configured the text field to truncate its contents:

myLabel.lineBreakMode = NSLineBreakMode.ByTruncatingTail

which works fine but I need to know when truncation occurs because in that situation I need to do something else in my UI.

RobertJoseph
  • 7,968
  • 12
  • 68
  • 113

1 Answers1

0

First of all, calculate number of character the label can take (determine the maximum number of characters a UILabel can take). Suppose, the label takes x characters then check, if(x < label.text.characters.count) { //Do you work.}

Community
  • 1
  • 1
ranjit.x.singh
  • 307
  • 4
  • 9