Can I underline the text of a NSTextField from interface builder?

前端 未结 2 1157
青春惊慌失措
青春惊慌失措 2021-02-14 10:57

Can I underline the text of a NSTextField from interface builder ?

So far, I\'ve only able to change its color. Is there a way to underline it ?

thanks

相关标签:
2条回答
  • 2021-02-14 11:26

    No, you'd have to do it in code. For example:

    NSMutableAttributedString *str = [[myTextField attributedStringValue] mutableCopy];
    
    [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0, str.length)];
    
    [myTextField setAttributedStringValue:str];
    
    [str release];
    
    0 讨论(0)
  • 2021-02-14 11:28

    Valid only for iOS

    Yes, set attributed text, then select the text, right mouse click > Font > Underline

    enter image description here

    0 讨论(0)
提交回复
热议问题