作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 Apple Watch 应用程序有一个复杂功能,我想添加第二种样式。我提出了一个非常基本的原型(prototype),但在表盘上看不到它可供选择。所以我正在尝试解决这个问题:
我的应用程序可以支持多种复杂功能吗? 我可以在表盘上同时运行两个复杂功能吗?(或者是非此即彼的情况,如果我有一个,iOS 不会显示第二个?)我尝试添加一个新的表盘,但它不允许我。
CLKComplicationTemplateModularSmallRingText
是 ModularSmall
复杂功能类型的有效模板吗?
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
if complication.family == .modularSmall {
let template = CLKComplicationTemplateModularSmallRingText()
template.ringStyle = .open
template.fillFraction = 0.3
let testProvider = CLKSimpleTextProvider(text: "TST", shortText: "S")
sleep.tintColor = UIColor.green
template.textProvider = testProvider
template.tintColor = UIColor.green
let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
// Pass the entry to ClockKit.
handler(entry)
}
else if complication.family == .graphicRectangular {
let template = CLKComplicationTemplateGraphicRectangularLargeImage()
//this complication works...
}
占位符模板目前相同:
func getPlaceholderTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
// Pass the template to ClockKit.
if complication.family == .modularSmall {
let template = CLKComplicationTemplateModularSmallRingText()
//...
我在复杂功能占位符文件中看到一个错误(但我正在 44 毫米设备上进行测试) - 将修复它并查看发生了什么情况。我是否为模块化并发症返回了错误的图像或错误的模板类型?我想要一个圆环规
最佳答案
事实证明我被苹果的文档误导了。我需要使用 GraphicCircular 复杂功能(WatchOS5 中的新功能)类型,而不是模块化(旧表盘)
func circularTemplate() -> CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText{
let template = CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText()
let gauge = CLKSimpleGaugeProvider(style: .ring, gaugeColor: UIColor.green), fillFraction: 0.3)
template.gaugeProvider = gauge
let random = arc4random() % 999
let middle = CLKSimpleTextProvider(text: "4.5", shortText: "4")
middle.tintColor = kRGBColorFromHex(0x657585)
template.tintColor = kRGBColorFromHex(0x657585)
template.centerTextProvider = middle
let bottom = CLKSimpleTextProvider(text: "-\(random)", shortText: "1..")
template.bottomTextProvider = bottom
return template
}
新风格:
关于iOS WatchOS5 - 如何为 watch 应用程序支持多个复杂功能系列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54875838/
我是一名优秀的程序员,十分优秀!