简体   繁体   English

我可以在界面构建器中为NSTextField的文本加下划线吗?

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

Can I underline the text of a NSTextField from interface builder ? 我可以在界面构建器中为NSTextField的文本加下划线吗?

So far, I've only able to change its color. 到目前为止,我只能改变它的颜色。 Is there a way to underline it ? 有没有办法强调它?

thanks 谢谢

Valid only for iOS 仅对iOS有效

Yes, set attributed text, then select the text, right mouse click > Font > Underline 是,设置属性文本,然后选择文本,单击鼠标右键>字体>下划线

在此输入图像描述

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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM