Truncate beginning of label

后端 未结 2 917
孤城傲影
孤城傲影 2021-01-23 23:44

I have a label (NSTextField) with text aligned right. When the text becomes too large to display, the end of the text is truncated (at the right edge of the label).

相关标签:
2条回答
  • 2021-01-23 23:55

    I'm not quite sure if this works for NSTextFields, I know it does for UILabels, but have you tried :

    myTextField.lineBreakMode = NSLineBreakMode.ByTruncatingHead
    
    0 讨论(0)
  • 2021-01-24 00:00

    What you're looking for is

    [[myTextField cell] setLineBreakMode: NSLineBreakByTruncatingHead];
    

    Swift:

    myTextField.cell.lineBreakMode = NSLineBreakMode.ByTruncatingHead
    
    0 讨论(0)
提交回复
热议问题