watchOS Complication Modular Small Image
Modular Small Image
3種類
- CLKComplicationTemplateModularSmallRingImage
- CLKComplicationTemplateModularSmallSimpleImage
- CLKComplicationTemplateModularSmallStackImage
CLKComplicationTemplateModularSmallRingImage
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { switch complication.family { case .modularSmall: let imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "questionnaire42")!) let modularTemplate = CLKComplicationTemplateModularSmallRingImage() modularTemplate.ringStyle = .closed modularTemplate.fillFraction = 0.7 modularTemplate.imageProvider = imageProvider let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: modularTemplate) handler(entry) default: handler(nil) } }
CLKComplicationTemplateModularSmallSimpleImage
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { switch complication.family { case .modularSmall: let imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "book64")!) let modularTemplate = CLKComplicationTemplateModularSmallSimpleImage() modularTemplate.imageProvider = imageProvider let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: modularTemplate) handler(entry) default: handler(nil) } }
CLKComplicationTemplateModularSmallStackImage
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { switch complication.family { case .modularSmall: let imageProvider = CLKImageProvider(onePieceImage: UIImage(named: "book64x34")!) let textProvider = CLKSimpleTextProvider(text: "Text") let modularTemplate = CLKComplicationTemplateModularSmallStackImage() modularTemplate.line1ImageProvider = imageProvider modularTemplate.line2TextProvider = textProvider modularTemplate.highlightLine2 = false let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: modularTemplate) handler(entry) default: handler(nil) } }