Swift 设置Apple Watch的颜色
我正在尝试为一个模块化的大复杂度设置标题文本颜色 我已经定制的手表面使用多色 但是,当我构建并运行此代码时,标题文本颜色仍然是白色(这是默认值) 为什么颜色没有更新Swift 设置Apple Watch的颜色,swift,watchos,apple-watch-complication,clockkit,Swift,Watchos,Apple Watch Complication,Clockkit,我正在尝试为一个模块化的大复杂度设置标题文本颜色 我已经定制的手表面使用多色 但是,当我构建并运行此代码时,标题文本颜色仍然是白色(这是默认值) 为什么颜色没有更新 private func templateForClassModularLarge(className: Schedule) -> CLKComplicationTemplateModularLargeStandardBody { let template = CLKComplicationTemplateModula
private func templateForClassModularLarge(className: Schedule) -> CLKComplicationTemplateModularLargeStandardBody {
let template = CLKComplicationTemplateModularLargeStandardBody()
let headerTextProvider = CLKSimpleTextProvider(text: "My Schedule", shortText: "Schedule")
headerTextProvider.tintColor = UIColor(red: 101, green: 153, blue: 255, alpha: 1)
template.headerTextProvider = headerTextProvider
template.body1TextProvider = CLKTimeIntervalTextProvider(startDate: className.start, endDate: className.end)
template.body2TextProvider = CLKSimpleTextProvider(text: className.description, shortText: className.shortDescription)
return template
}
UIColor
参数类型是CGFloat
,指定为0.0到1.0之间的值
由于RGB参数大于1,因此颜色最终为白色,即:
UIColor(red: 1, green: 1, blue: 1, alpha: 1)
要解决此问题,只需将着色剂颜色更改为
headerTextProvider.tintColor = UIColor(red: 101/255, green: 153/255, blue: 255/255, alpha: 1)
UIColor
参数类型是CGFloat
,指定为0.0到1.0之间的值
由于RGB参数大于1,因此颜色最终为白色,即:
UIColor(red: 1, green: 1, blue: 1, alpha: 1)
要解决此问题,只需将着色剂颜色更改为
headerTextProvider.tintColor = UIColor(red: 101/255, green: 153/255, blue: 255/255, alpha: 1)