2016-04-25 103 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)