我有一个短语将是整个复杂性。有时它足够短,可以单独占据标题。然而,有时它太长了,我需要它来包裹身体线条。我一生都无法弄清楚如何获得这种行为。例如:
let phrase1 = "Short phrase"
phrase1
足够短以适合标题行。
let phrase2 = "Very very very very very very long phrase"
对于phrase2
, 仅"Very very ve..."
显示在标题行上。我需要将其余部分显示在身体线条上。
这是代码:
let headerTextProvider = CLKSimpleTextProvider(text: string) //string is either phrase1 or phrase2
let template = CLKComplicationTemplateModularLargeStandardBody()
template.headerTextProvider = headerTextProvider
let timelineEntry = CLKComplicationTimelineEntry(date: NSDate(), complicationTemplate: template)
handler(timelineEntry)