2016-04-25 43 views
0

我正在尝试设置Modular Large复杂功能的标题文本颜色。为Apple Watch复杂功能设置tintColor

我已经定制了手表脸以使用多色。

但是,当我构建并运行此代码时,标题文本颜色仍为白色(这是默认设置)。

为什么不更新颜色?

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 
} 

回答

3

UIColor参数类型CGFloat,指定为从0.0到1.0的值。

因为你RGB参数大于1,颜色最终是白色的,这将是:

UIColor(red: 1, green: 1, blue: 1, alpha: 1) 

要解决此问题,只需将tintColor改变

headerTextProvider.tintColor = UIColor(red: 101/255, green: 153/255, blue: 255/255, alpha: 1)