我可以在界面生成器中给NSTextField的文本加下划线吗? [英] Can I underline the text of a NSTextField from interface builder?

查看:69
本文介绍了我可以在界面生成器中给NSTextField的文本加下划线吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 ?

谢谢

推荐答案

否,则必须在代码中完成。例如:

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

这篇关于我可以在界面生成器中给NSTextField的文本加下划线吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆