jjzjj

WKInterfaceButton

全部标签

ios - 设置 WKInterfaceButton 标题颜色 - WatchKit

有没有办法以编程方式更改WatchKitWKInterfaceButton标题的颜色?我知道我可以在Storyboard中更改它,但我需要在代码中更改它。根据Appledocumentation它没有说明是否允许这样的操作。我确实尝试查看WKInterfaceButton的所有可用方法,其中有一个用于setBackgroundColor但不是用于标题颜色。我错过了什么? 最佳答案 我没试过,但看起来你可以使用setAttributedTitle:并且其中一个属性可以是NSForegroundColorAttributeName以及你

ios - WKInterfaceButton 在 WatchKit 中的隐藏状态

有没有办法查看WatchKit中WKInterfaceButton的当前隐藏状态? 最佳答案 看来你不能那样做。但是您可以使用状态存储自己的变量并使用它。您可以在下面查看按钮父类的定义。publicclassWKInterfaceObject:NSObject{publicfuncsetHidden(hidden:Bool)publicfuncsetAlpha(alpha:CGFloat)@available(watchOS2.0,*)publicfuncsetHorizontalAlignment(horizontalAlignm

ios - 单击时更改按钮背景颜色- WatchKit

按钮背景最初是白色的,没有背景。需要背景改成如下十六进制值:#cd9037@IBOutletweakvarzeroTapped:WKInterfaceButton!@IBActionfuncZeroTapped(){zeroTapped.setBackgroundColor(UIColor(red:205,green:144,blue:55,alpha:1.0))vartime=dispatch_time(DISPATCH_TIME_NOW,TIMEOUT)dispatch_after(time,dispatch_get_main_queue(),{self.appendValue(0

swift - 如何从 WKInterfaceButton 获取标题

要获得标题,有一个函数:setTitle但是如何获取WKInterfaceButton的标题作为字符串呢?我在https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceButton_class/index.html中没有找到任何东西 最佳答案 您无法获取任何WKInterfaceUI元素的状态,例如按钮(WKInterfaceButton)标签(WKInterfaceLabel)等。我认为这是Apple

swift - 如何从 WKInterfaceButton 获取标题

要获得标题,有一个函数:setTitle但是如何获取WKInterfaceButton的标题作为字符串呢?我在https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceButton_class/index.html中没有找到任何东西 最佳答案 您无法获取任何WKInterfaceUI元素的状态,例如按钮(WKInterfaceButton)标签(WKInterfaceLabel)等。我认为这是Apple

ios - WKInterfaceTable 中的 WKInterfaceButton 事件处理

我有一个带有WKInterfaceButton的WKInterfaceTableTableView。如何从TableView向按钮添加目标操作。由于没有标签属性,我无法处理它。 最佳答案 如果您的WKInterfaceButton包含在行Controller中,这里有一种方法可以确定哪一行的按钮被点击:将您的WKInterfaceButton添加到行Controller,并使用界面构建器将按钮的操作连接到您的行Controller类向您的行Controller添加一个属性,允许您引用您的数据(例如,对您的数据或标签的弱引用)向行Co

swift - 我可以以编程方式创建 WKInterfaceButton 吗?

如果这完全可能,只是一个简单的问题:我可以通过编程方式为AppleWatch创建WKInterfaceButton元素吗?还是我必须在InterfaceBuilder中布局所有内容而不能在watch上动态添加UI元素?到目前为止我还没有找到类似this的东西对于带有watchOS2的AppleWatch,我不清楚documentation.感谢任何见解。 最佳答案 您不能以编程方式创建WKInterfaceObjects并将它们添加到View层次结构中。唯一的异常(exception)是WKInterfaceControllers,