gpt4 book ai didi

ios - 以编程方式获取 WKInterfaceGroup 的背景颜色 (WatchKit)

转载 作者:行者123 更新时间:2023-11-28 21:25:56 25 4
gpt4 key购买 nike

如何以编程方式获取 WKInterfaceGroup 对象的背景颜色?

您可以 set the value使用

- (void)setBackgroundColor:(nullable UIColor *)color;

但是你也能得到吗?

最佳答案

您可以在接口(interface)对象上设置值,但不能获取其属性的当前值。

这个答案可以在 WKInterfaceObject 中找到父类(super class)文档:

Communication between an interface object in your extension and the corresponding interface element in your Watch app is one way. You can set the values of an interface object, but you cannot get the current values. If you want to know the current value of an attribute, you must save the value yourself.

下面是一个示例,显示如何维护您自己的组颜色值:

@IBOutlet weak var myGroup: WKInterfaceGroup!
var myGroupBackgroundColor: UIColor?

// Set the group's color, also save the color for future reference
myGroupBackgroundColor = UIColor.blue()
myGroup.setBackgroundColor(myGroupBackgroundColor)

然后您可以使用 myGroupBackgroundColor 属性获取组的当前颜色。

关于ios - 以编程方式获取 WKInterfaceGroup 的背景颜色 (WatchKit),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38055637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com