当按钮被选中时,有没有办法改变它的文本颜色?
我试过这样的方法:
property myButton : missing value
myButton's setTintColor:(current application's NSColor's cyanColor)但我得到的错误如下:
-NSButton setTintColor::无法识别的选择器发送到实例0x7fc865f2d000 (错误-10000)
发布于 2021-04-23 06:18:36
要将颜色等属性应用于按钮标题,可以使用NSAttributedString,例如:
set buttonTitle to myButton's title -- get current title
set attrString to current application's NSMutableAttributedString's alloc's initWithString:buttonTitle
attrString's addAttribute:(current application's NSForegroundColorAttributeName) value:(current application's NSColor's cyanColor) range:{0, buttonTitle's |length|}
set myButton's attributedTitle to attrStringhttps://stackoverflow.com/questions/67201107
复制相似问题