我有一句話是整個併發症。有時它足夠短,只能單獨佔據標題。但是,有時它太長了,我需要它包裹到身體線上。我不能爲我的生活弄清楚如何得到這種行爲。例如:如何獲得併發症的標題以包裝到身體線上?
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)
雖然'body2TextProvider'是可選的,'body1TextProvider'和'headerTextProvider'沒有標記爲可選項。也許蘋果希望[ModularLargeStandardBody併發症](https://developer.apple.com/library/watchos/documentation/ClockKit/Reference/CLKComplicationTemplateModularLargeStandardBody_class/index.html#//apple_ref/occ/instp/CLKComplicationTemplateModularLargeStandardBody/headerTextProvider)同時擁有標題行和正文文本? –