watchOS Complication Graphic Circular
Graphic Circular
8種類
- CLKComplicationTemplateGraphicCircularImage
- CLKComplicationTemplateGraphicCircularStackImage
- CLKComplicationTemplateGraphicCircularStackText
- CLKComplicationTemplateGraphicCircularClosedGaugeImage
- CLKComplicationTemplateGraphicCircularOpenGaugeImage
- CLKComplicationTemplateGraphicCircularClosedGaugeText
- CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText
- CLKComplicationTemplateGraphicCircularOpenGaugeRangeText
CLKComplicationTemplateGraphicCircularImage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | func getCurrentTimelineEntry ( for complication : CLKComplication , withHandler handler : @escaping ( CLKComplicationTimelineEntry ?) - > Void ) { switch complication . family { case . graphicCircular : let imageProvider = CLKFullColorImageProvider ( fullColorImage : UIImage ( named : "kumonosu94" )!) let circularTemplate = CLKComplicationTemplateGraphicCircularImage () circularTemplate . imageProvider = imageProvider let entry = CLKComplicationTimelineEntry ( date : Date (), complicationTemplate : circularTemplate ) handler ( entry ) default : handler ( nil ) } } |
CLKComplicationTemplateGraphicCircularStackImage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | func getCurrentTimelineEntry ( for complication : CLKComplication , withHandler handler : @escaping ( CLKComplicationTimelineEntry ?) - > Void ) { switch complication . family { case . graphicCircular : let imageProvider = CLKFullColorImageProvider ( fullColorImage : UIImage ( named : "kumonosu62x32" )!) let textProvider = CLKSimpleTextProvider ( text : "Text" ) let circularTemplate = CLKComplicationTemplateGraphicCircularStackImage () circularTemplate . line1ImageProvider = imageProvider circularTemplate . line2TextProvider = textProvider let entry = CLKComplicationTimelineEntry ( date : Date (), complicationTemplate : circularTemplate ) handler ( entry ) default : handler ( nil ) } } |
CLKComplicationTemplateGraphicCircularStackText
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | func getCurrentTimelineEntry ( for complication : CLKComplication , withHandler handler : @escaping ( CLKComplicationTimelineEntry ?) - > Void ) { switch complication . family { case . graphicCircular : let text1Provider = CLKSimpleTextProvider ( text : "xyz" ) let text2Provider = CLKSimpleTextProvider ( text : "Text" ) text2Provider . tintColor = UIColor . green let circularTemplate = CLKComplicationTemplateGraphicCircularStackText () circularTemplate . line1TextProvider = text1Provider circularTemplate . line2TextProvider = text2Provider let entry = CLKComplicationTimelineEntry ( date : Date (), complicationTemplate : circularTemplate ) handler ( entry ) default : handler ( nil ) } } |
CLKComplicationTemplateGraphicCircularClosedGaugeImage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | func getCurrentTimelineEntry ( for complication : CLKComplication , withHandler handler : @escaping ( CLKComplicationTimelineEntry ?) - > Void ) { switch complication . family { case . graphicCircular : let weatherColors = [ UIColor . cyan , UIColor . yellow , UIColor . red ] let weatherColorLocations = [ 0.0 , 0.3 , 1.0 ] let weatherGaugeProvider = CLKSimpleGaugeProvider ( style : . ring , gaugeColors : weatherColors , gaugeColorLocations : weatherColorLocations as [ NSNumber ], fillFraction : 1.0 ) let imageProvider = CLKFullColorImageProvider ( fullColorImage : UIImage ( named : "kumonosu32" )!) let circularTemplate = CLKComplicationTemplateGraphicCircularClosedGaugeImage () circularTemplate . gaugeProvider = weatherGaugeProvider circularTemplate . imageProvider = imageProvider let entry = CLKComplicationTimelineEntry ( date : Date (), complicationTemplate : circularTemplate ) handler ( entry ) default : handler ( nil ) } } |
CLKComplicationTemplateGraphicCircularOpenGaugeImage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | func getCurrentTimelineEntry ( for complication : CLKComplication , withHandler handler : @escaping ( CLKComplicationTimelineEntry ?) - > Void ) { switch complication . family { case . graphicCircular : let weatherColors = [ UIColor . cyan , UIColor . yellow , UIColor . red ] let weatherColorLocations = [ 0.0 , 0.3 , 1.0 ] let weatherGaugeProvider = CLKSimpleGaugeProvider ( style : . ring , gaugeColors : weatherColors , gaugeColorLocations : weatherColorLocations as [ NSNumber ], fillFraction : 0.8 ) let textProvider = CLKSimpleTextProvider ( text : "xyz" ) textProvider . tintColor = UIColor . purple let imageProvider = CLKFullColorImageProvider ( fullColorImage : UIImage ( named : "kumonosu48" )!) let circularTemplate = CLKComplicationTemplateGraphicCircularOpenGaugeImage () circularTemplate . gaugeProvider = weatherGaugeProvider circularTemplate . centerTextProvider = textProvider circularTemplate . bottomImageProvider = imageProvider let entry = CLKComplicationTimelineEntry ( date : Date (), complicationTemplate : circularTemplate ) handler ( entry ) default : handler ( nil ) } } |
CLKComplicationTemplateGraphicCircularClosedGaugeText
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | func getCurrentTimelineEntry ( for complication : CLKComplication , withHandler handler : @escaping ( CLKComplicationTimelineEntry ?) - > Void ) { switch complication . family { case . graphicCircular : let weatherColors = [ UIColor . cyan , UIColor . yellow , UIColor . red ] let weatherColorLocations = [ 0.0 , 0.3 , 1.0 ] let weatherGaugeProvider = CLKSimpleGaugeProvider ( style : . ring , gaugeColors : weatherColors , gaugeColorLocations : weatherColorLocations as [ NSNumber ], fillFraction : 0.6 ) let textProvider = CLKSimpleTextProvider ( text : "xyz" ) textProvider . tintColor = UIColor . gray let circularTemplate = CLKComplicationTemplateGraphicCircularClosedGaugeText () circularTemplate . gaugeProvider = weatherGaugeProvider circularTemplate . centerTextProvider = textProvider let entry = CLKComplicationTimelineEntry ( date : Date (), complicationTemplate : circularTemplate ) handler ( entry ) default : handler ( nil ) } } |
CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | func getCurrentTimelineEntry ( for complication : CLKComplication , withHandler handler : @escaping ( CLKComplicationTimelineEntry ?) - > Void ) { switch complication . family { case . graphicCircular : let weatherColors = [ UIColor . cyan , UIColor . yellow , UIColor . red ] let weatherColorLocations = [ 0.0 , 0.5 , 1.0 ] let weatherGaugeProvider = CLKSimpleGaugeProvider ( style : . ring , gaugeColors : weatherColors , gaugeColorLocations : weatherColorLocations as [ NSNumber ], fillFraction : 0.4 ) let centerTextProvider = CLKSimpleTextProvider ( text : "xyz" ) let buttomTextProvider = CLKSimpleTextProvider ( text : "40%" ) let circularTemplate = CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText () circularTemplate . gaugeProvider = weatherGaugeProvider circularTemplate . centerTextProvider = centerTextProvider circularTemplate . bottomTextProvider = buttomTextProvider let entry = CLKComplicationTimelineEntry ( date : Date (), complicationTemplate : circularTemplate ) handler ( entry ) default : handler ( nil ) } } |
CLKComplicationTemplateGraphicCircularOpenGaugeRangeText
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | func getCurrentTimelineEntry ( for complication : CLKComplication , withHandler handler : @escaping ( CLKComplicationTimelineEntry ?) - > Void ) { switch complication . family { case . graphicCircular : let weatherColors = [ UIColor . cyan , UIColor . yellow , UIColor . red ] let weatherColorLocations = [ 0.0 , 0.5 , 1.0 ] let weatherGaugeProvider = CLKSimpleGaugeProvider ( style : . ring , gaugeColors : weatherColors , gaugeColorLocations : weatherColorLocations as [ NSNumber ], fillFraction : 0.4 ) let centerTextProvider = CLKSimpleTextProvider ( text : "xyz" ) let lowTempText = CLKSimpleTextProvider ( text : "52" ) lowTempText . tintColor = UIColor . cyan let highTempText = CLKSimpleTextProvider ( text : "89" ) highTempText . tintColor = UIColor . red let circularTemplate = CLKComplicationTemplateGraphicCircularOpenGaugeRangeText () circularTemplate . gaugeProvider = weatherGaugeProvider circularTemplate . centerTextProvider = centerTextProvider circularTemplate . leadingTextProvider = lowTempText circularTemplate . trailingTextProvider = highTempText let entry = CLKComplicationTimelineEntry ( date : Date (), complicationTemplate : circularTemplate ) handler ( entry ) default : handler ( nil ) } } |