問題如下:
var drawAttributes = {
NSFontAttributeName: font,
NSForegroundColorAttributeName: DTSColor.defaultLightGrayTextColor()
};
直接通過上面的js代碼是不能起到設(shè)置文本屬性作用的署辉,原因是NSFontAttributeName、NSForegroundColorAttributeName js中不能正確識別處理,我們需要獲取字典對應(yīng)的常量字符串key值。
那么怎么獲取NSFontAttributeName族沃、NSForegroundColorAttributeName的常量字符串呢,直接通過NSLog既可以獲取
如下:
Paste_Image.png
最終可以通過以下js代碼實(shí)現(xiàn)文本渲染
var drawAttributes = {
"NSFont": font,
"NSColor": DTSColor.defaultLightGrayTextColor()
};