有没有一种简单的方法来识别 Watch Kit 中的文本颜色 - Swift

Is there an easy way to identify the colour of text in Watch Kit - Swift

我正在创建一个程序,它使标签成为随机 UIcolor,例如 'red' 或 'green'。我想识别那种颜色。我知道如何在 iPhone 上执行此操作,但我如何在 whatchKit 中执行此操作。这就是我对 iPhone:

if ageLabel.textColor == UIColor.green {
    print("Its green")
}

简短回答:。 如果你查看 the class reference of WKInterfaceLabel,你会发现,它只有设置文本和文本属性的方法,但没有 getter 方法。但是,如果您以编程方式设置 textColor,则可以在每次调用 setTextColor(_:) 函数时将设置的颜色存储在单独的变量中。