最佳答案
Is there a way to set the font to be underlined?
不,但这只是因为你找错了对象。
“字体”不能加下划线(至少我不这么认为),但字符串可以。
看看 NSAttributedString...您创建一个“属性”字典,将其附加到要绘制的 NSString...“倾斜”,(是否表示斜体),“居中”...所有这些东西。所以它是这样的:
[textAttrDict setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
[textStr drawInRect:textRect withAttributes:textAttrDict];
在标题中搜索 NSUnderlineStyleSingle 以找到您想要的确切枚举...
关于cocoa - 在 Cocoa 中创建带下划线的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25737723/