如何使用AppleScript更改按钮的颜色文本?

如何使用AppleScript更改按钮的颜色文本?,applescript,applescript-objc,Applescript,Applescript Objc,当按钮被选中时,有没有办法改变按钮文本的颜色 我试过这样的方法: property myButton : missing value myButton's setTintColor:(current application's NSColor's cyanColor) 但我得到的错误如下: -[NSButton setTintColor::发送到实例0x7fc865f2d000(错误-10000)的无法识别的选择器要将颜色等属性应用于按钮标题,可以使用,例如: set buttonT

当按钮被选中时,有没有办法改变按钮文本的颜色

我试过这样的方法:

property myButton : missing value

myButton's setTintColor:(current application's NSColor's cyanColor)
但我得到的错误如下:


-[NSButton setTintColor::发送到实例0x7fc865f2d000(错误-10000)的无法识别的选择器要将颜色等属性应用于按钮标题,可以使用,例如:

    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 attrString

什么样的按钮?请注意,
tintColor
来自iOS。嵌入式按钮或按钮。这些按钮在按下时没有备用标题,只有具有状态的按钮,如复选框。你只是想设置标题颜色吗?是的,我只是想定义标题颜色。谢谢,它很有魅力!我可以使用nshmoTemplate更改NSImageView的颜色吗?图像视图不是文本,但如果使用Mojave或更高版本,它确实具有
contentTintColor
属性。相同错误:-[NSImageView setcontentTintColor::]:发送到实例0x7fb6dec71c50的无法识别的选择器(错误-10000)方法名称区分大小写-setter方法在添加
set
时大写,因此名称应为
setContentTintColor:
。它工作起来很有魅力!谢谢