{"id":1688,"date":"2022-06-14T23:36:28","date_gmt":"2022-06-14T14:36:28","guid":{"rendered":"https:\/\/www.typea.info\/blog\/?p=1688"},"modified":"2022-06-14T23:41:49","modified_gmt":"2022-06-14T14:41:49","slug":"swift_watchos_watchface_complication","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2022\/06\/14\/swift_watchos_watchface_complication\/","title":{"rendered":"Swift watchOS \u6587\u5b57\u76e4\u306b\u60c5\u5831\u3092\u8868\u793a\u3059\u308b"},"content":{"rendered":"<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2022\/06\/11\/swift_watchos_complication_watchface_run_app\/\">\u6587\u5b57\u76e4\u306b\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u30a2\u30a4\u30b3\u30f3\u3092\u8ffd\u52a0\u3057\u3001\u30a2\u30d7\u30ea\u3092\u8d77\u52d5\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f<\/a>\u306e\u3067\u3001\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3057\u3066\u307f\u308b\u3002<\/p>\n<h2><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/creating_a_timeline_entry\">1.\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u4f5c\u6210\u3059\u308b<\/a><\/h2>\n<ul>\n<li>\u30a2\u30d7\u30ea\u56fa\u6709\u306e\u30c7\u30fc\u30bf\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u307e\u3068\u3081\u3001\u305d\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u5bfe\u3057\u3066\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n<li>ClockKit\u306f\u5b9a\u671f\u7684\u306b\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u304b\u3089\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u8981\u6c42\u3057\u307e\u3059\u3002<\/li>\n<li>\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u306f\u3001\u30a2\u30d7\u30ea\u306e\u30c7\u30fc\u30bf\u3067\u8a2d\u5b9a\u3057\u305f\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3001ClockKit\u304c\u305d\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8868\u793a\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3092\u6307\u5b9a\u3059\u308b\u65e5\u4ed8\u3067\u69cb\u6210\u3055\u308c\u307e\u3059\u3002<\/li>\n<li>\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u306f\u30a2\u30d7\u30ea\u56fa\u6709\u306e\u30c7\u30fc\u30bf\u3092ClockKit\u304c\u753b\u9762\u4e0a\u306b\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u3057\u307e\u3059\u3002<\/li>\n<li>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u3001\u63d0\u4f9b\u3055\u308c\u305fCLKComplication\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8abf\u3079\u3001\u9069\u5207\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u9078\u629e\u3057\u3001\u30a2\u30d7\u30ea\u304b\u3089\u306e\u30c7\u30fc\u30bf\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u5165\u308c\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<h3>1.1 \u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8abf\u3079\u308b<\/h3>\n<ul>\n<li>ClockKit \u304c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8981\u6c42\u3059\u308b\u3068\u3001\u5e38\u306b\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8a18\u8ff0\u3057\u305f CLKComplication \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002<\/li>\n<li>\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u30a2\u30d7\u30ea\u304c\u5b9a\u7fa9\u3059\u308b\u8b58\u5225\u5b50\u3068\u3001<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\">CLKComplicationFamily<\/a>\u5217\u6319\u578b\u306e\u30d5\u30a1\u30df\u30ea\u30fc\u3092\u6301\u3061\u307e\u3059\u3002<\/li>\n<li>\u5404\u8b58\u5225\u5b50\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30d5\u30a1\u30df\u30ea\u30fc\u306e\u500b\u5225\u306e\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30bf\u30a4\u30d7\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/li>\n<li>\u4f5c\u6210\u3059\u308b\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u6c7a\u5b9a\u3059\u308b\u306b\u306f\u3001\u8b58\u5225\u5b50\u3092\u8abf\u3079\u307e\u3059\u3002<\/li>\n<li>watchOS 7\u4ee5\u964d\u3067\u306f\u3001\u30a2\u30d7\u30ea\u306f\u30d5\u30a1\u30df\u30ea\u30fc\u3054\u3068\u306b1\u3064\u307e\u305f\u306f\u8907\u6570\u306e\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u63d0\u4f9b\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u5929\u6c17\u4e88\u5831\u30a2\u30d7\u30ea\u306f\u3001Condition\u3001Temperature\u3001Precipitation\u306e\u5404\u8b58\u5225\u5b50\u306b\u5bfe\u3057\u3066\u5225\u3005\u306e\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n<pre class=\"prettyprint\">switch complication.identifier {\ncase complicationConditionIdentifier:\n    templateOrNil = myGetConditionTemplate(for: family, date: date)\n    \ncase complicationTemperatureIdentifier:\n    templateOrNil = myGetTemperatureTemplate(for: family, date: date)\n    \ncase complicationPrecipitationIdentifier:\n    templateOrNil = myGetPrecipitationPercentageTemplate(for: family, date: date)\n<\/pre>\n<h3>1.2 \u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30df\u30ea\u30fc<\/h3>\n<ul>\n<li>ClockKit \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306f\u3001\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30d5\u30a1\u30df\u30ea\u30fc\u306b\u6574\u7406\u3057\u307e\u3059\u3002<\/li>\n<li>\u5404\u30d5\u30a1\u30df\u30ea\u30fc\u306f\u3001\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30b5\u30a4\u30ba\u3068\u5f62\u72b6\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/li>\n<li>\u30d5\u30a1\u30df\u30ea\u30fc\u3092\u8abf\u3079\u308b\u3068\u3001\u3069\u306e\u7a2e\u985e\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u4f7f\u7528\u3067\u304d\u308b\u304b\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/li>\n<li>\u30d5\u30a1\u30df\u30ea\u30fc\u306e\u5b8c\u5168\u306a\u30ea\u30b9\u30c8\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\">CLKComplicationFamily<\/a> \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ul>\n<pre class=\"prettyprint\">switch complication.family {\ncase .circularSmall:\n    \/\/ Create a template from the circular small family.\n    \ncase .modularSmall:\n    \/\/ Create a template from the modular small family.\n    \ncase .modularLarge:\n    \/\/ Create a template from the modular large family.\n    \n\/\/ Continue with all the templates supported by the specified type.\n    \n@unknown default:\n    print(\"*** Unknown Complication Family: \\(complication.family) ***\")\n    \/\/ Handle the error here.\n}\n<\/pre>\n<p>1.2.1\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\/circularsmall\">CLKComplicationFamily.circularSmall<\/a><br \/>\n<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/circular_small\">Circular Small<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/circularsmall.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"circularsmall.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/circularsmall.png\" alt=\"circularsmall\" width=\"253\" height=\"196\" border=\"0\" \/><\/a><\/p>\n<h4>1.2.2\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\/extralarge\">CLKComplicationFamily.extraLarge<\/a><br \/>\n<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/extra_large\">Extra Large<\/a><\/h4>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/extralarge.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"extralarge.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/extralarge.png\" alt=\"extralarge\" width=\"262\" height=\"199\" border=\"0\" \/><\/a><\/p>\n<p>1.2.3\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\/modularsmall\">CLKComplicationFamily.modularSmall<\/a><br \/>\n<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/modular_small\">Modular Small<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/modularsmall.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"modularsmall.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/modularsmall.png\" alt=\"modularsmall\" width=\"288\" height=\"195\" border=\"0\" \/><\/a><br \/>\n1.2.4\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\/modularlarge\">CLKComplicationFamily.modularLarge<\/a><br \/>\n<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/modular_large\">Modular Large<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/modularlarge.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"modularlarge.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/modularlarge.png\" alt=\"modularlarge\" width=\"277\" height=\"198\" border=\"0\" \/><\/a><\/p>\n<p>1.2.5\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\/utilitariansmall\">CLKComplicationFamily.utilitarianSmall<\/a><br \/>\n<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/utilitarian\">Utilitarian<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/utilitariansmall.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"utilitariansmall.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/utilitariansmall.png\" alt=\"utilitariansmall\" width=\"275\" height=\"187\" border=\"0\" \/><\/a><br \/>\n1.2.5\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\/utilitariansmallflat\">CLKComplicationFamily.utilitarianSmallFlat<\/a><br \/>\n<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/utilitarian\">Utilitarian<\/a><br \/>\n<a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/utilitariansmallflat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"utilitariansmallflat.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/utilitariansmallflat.png\" alt=\"utilitariansmallflat\" width=\"295\" height=\"208\" border=\"0\" \/><\/a><br \/>\n1.2.6\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationfamily\/utilitarianlarge\">CLKComplicationFamily.utilitarianLarge<\/a><br \/>\n<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/utilitarian\">Utilitarian<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/utilitarianlarge.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"utilitarianlarge.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/utilitarianlarge.png\" alt=\"utilitarianlarge\" width=\"288\" height=\"186\" border=\"0\" \/><\/a><\/p>\n<h3>1.3 \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u57cb\u3081\u308b\u30c7\u30fc\u30bf\u30d7\u30ed\u30d0\u30a4\u30c0\u306e\u4f5c\u6210<\/h3>\n<ul>\n<li>\u30c7\u30fc\u30bf\u30fb\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306f\u751f\u306e\u5024\u3092\u53d7\u3051\u53d6\u308a\u3001\u305d\u308c\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u7528\u306b\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3057\u307e\u3059\u3002<\/li>\n<li>\u4f8b\u3048\u3070\u3001CLKSimpleTextProvider\u306f\u3001\u77ed\u3044\u6587\u5b57\u5217\u3068\u9577\u3044\u6587\u5b57\u5217\u306e2\u3064\u306e\u6587\u5b57\u5217\u3092\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002<\/li>\n<li>\u4e21\u65b9\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001ClockKit \u306f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30b5\u30a4\u30ba\u306b\u6700\u9069\u306a\u6587\u5b57\u5217\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<pre class=\"prettyprint\">let temperature = myCity.temperature(date)\n\nlet nameProvider = CLKSimpleTextProvider(\n    text: myCity.name,\n    shortText: myCity.abbreviation)\n\nlet temperatureProvider = CLKSimpleTextProvider(\n    text: \"\\(longNumberFormatter.string(from: NSNumber(value: temperature)) ?? \"Unknown\")\u00ba F\",\n    shortText: shortNumberFormatter.string(from: NSNumber(value: temperature)) ?? \"??\")<\/pre>\n<ul>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clksimpletextprovider\">CLKSimpleTextProvider<\/a><\/li>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkdatetextprovider\">CLKDateTextProvider<\/a><\/li>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clktimetextprovider\">CLKTimeTextProvider<\/a><\/li>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkrelativedatetextprovider\">CLKRelativeDateTextProvider<\/a><\/li>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clktimeintervaltextprovider\">CLKTimeIntervalTextProvider<\/a><\/li>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkimageprovider\">CLKImageProvider<\/a><\/li>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkfullcolorimageprovider\">CLKFullColorImageProvider<\/a><\/li>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clksimplegaugeprovider\">CLKSimpleGaugeProvider<\/a><\/li>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clktimeintervalgaugeprovider\">CLKTimeIntervalGaugeProvider<\/a><\/li>\n<\/ul>\n<blockquote><p>CLKRelativeDateTextProvider\u3084CLKTimeIntervalGaugeProvider\u306a\u3069\u3001\u4e00\u90e8\u306e\u30c7\u30fc\u30bf\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306f\u3001\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u5b9f\u884c\u30d0\u30b8\u30a7\u30c3\u30c8\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u305a\u306b\u3001\u6642\u9593\u306e\u7d4c\u904e\u306b\u4f34\u3063\u3066\u81ea\u52d5\u7684\u306b\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u66f4\u65b0\u3059\u308b\u3082\u306e\u3067\u3059\u3002<\/p><\/blockquote>\n<p>\u30c7\u30fc\u30bf\u30fb\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u3001\u30c7\u30fc\u30bf\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"prettyprint\">let template = CLKComplicationTemplateModularSmallStackText(\n    line1TextProvider: temperatureProvider,\n    line2TextProvider: nameProvider)\n<\/pre>\n<h4>1.3.1 ModularSmall\u7528\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4f5c\u6210\u7528\u4f8b<\/h4>\n<p>1.3.1.1\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationtemplatemodularsmallstacktext\">CLKComplicationTemplateModularSmallStackText<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/samallstack.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"samallstack.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/samallstack.png\" alt=\"samallstack\" width=\"262\" height=\"192\" border=\"0\" \/><\/a><\/p>\n<p>1.3.1.2\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationtemplatemodularsmallringtext\">CLKComplicationTemplateModularSmallRingText<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/smallring.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"smallring.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/smallring.png\" alt=\"smallring\" width=\"312\" height=\"221\" border=\"0\" \/><\/a><\/p>\n<p>1.3.1.3\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationtemplatemodularsmallcolumnstext\">CLKComplicationTemplateModularSmallColumnsText<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/smallcolumns.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"smallcolumns.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/smallcolumns.png\" alt=\"smallcolumns\" width=\"279\" height=\"227\" border=\"0\" \/><\/a><\/p>\n<h3>1.4 \u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u7528\u3059\u308b<\/h3>\n<ul>\n<li><a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationdescriptor\">CLKComplicationDescriptor<\/a> \u30af\u30e9\u30b9\u306e userInfo \u304a\u3088\u3073 userActivity \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u95a2\u3059\u308b\u8ffd\u52a0\u30c7\u30fc\u30bf\u3092\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u3053\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u3001\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u306e\u4f5c\u6210\u3092\u7c21\u5358\u306b\u3057\u305f\u308a\u3001\u30a2\u30d7\u30ea\u5185\u3067\u7279\u5b9a\u306e\u30b7\u30fc\u30f3\u3092\u8d77\u52d5\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n<blockquote><p>\u4f8b\u3048\u3070\u3001Dynamically Define Descriptors\u306b\u3042\u308b\u3088\u3046\u306b\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u304a\u6c17\u306b\u5165\u308a\u90fd\u5e02\u30ea\u30b9\u30c8\u304b\u3089\u3001\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30bb\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8b58\u5225\u5b50\u3092\u30d1\u30fc\u30b9\u3059\u308b\u4ee3\u308f\u308a\u306b\u3001\u90fd\u5e02\u3068\u5929\u6c17\u306e\u30c7\u30fc\u30bf\u578b\u3092\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306euserInfo\u8f9e\u66f8\u306b\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u9078\u629e\u3057\u5145\u586b\u3059\u308b\u524d\u306b\u3001\u8f9e\u66f8\u304b\u3089\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u53d6\u308a\u307e\u3059\u3002<\/p><\/blockquote>\n<pre class=\"prettyprint\">let city: City\n\/\/ Read the city id from the complication\u2019s userInfo dictionary.\nif let cityID = complication.userInfo?[myCityIDKey] as? String {\n city = myData.lookupCity(byID: cityID) ?? myData.currentCity\n} else {\n city = myData.currentCity\n}\nlet nameProvider = CLKSimpleTextProvider(\n text: city.name,\n shortText: city.abbreviation)\n\/\/ Read the complication type from the userInfo dictionary.\nlet typeIdentifier = complication.userInfo?[myTypeIdentifierKey] as? String ?? \u201cUndefined\u201d<\/pre>\n<h3>1.5 \u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210<\/h3>\n<ul>\n<li>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u5e0c\u671b\u3059\u308b\u65e5\u4ed8\u3092\u4f7f\u7528\u3057\u3066\u3001<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationtimelineentry\">CLKComplicationTimelineEntry<\/a>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n<li>\u73fe\u5728\u306e\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u306e\u5834\u5408\u3001\u73fe\u5728\u6642\u523b\u3068\u540c\u3058\u304b\u305d\u308c\u4ee5\u524d\u306e\u65e5\u4ed8\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<li>\u672a\u6765\u306e\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u9805\u76ee\u306b\u3064\u3044\u3066\u306f\u3001\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3059\u308b\u65e5\u4ed8\u3068\u6642\u9593\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>\u4f1a\u8b70\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5834\u5408\u3001\u958b\u59cb\u4e88\u5b9a\u6642\u523b\u306e\u524d\u306b\u4f1a\u8b70\u306b\u95a2\u3059\u308b\u60c5\u5831\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u672a\u6765\u306eTimeline\u30a8\u30f3\u30c8\u30ea\u30fc\u306e\u4f5c\u6210\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u306f\u3001<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/loading_future_timeline_events\">\u672a\u6765\u306eTimeline\u30a4\u30d9\u30f3\u30c8\u3092\u8aad\u307f\u8fbc\u3080<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ul>\n<h3>1.6\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/loading_future_timeline_events\">\u672a\u6765\u306e\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a4\u30d9\u30f3\u30c8\u3092\u8aad\u307f\u8fbc\u3080<\/a><\/h3>\n<ul>\n<li>ClockKit\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u6642\u8a08\u3092\u898b\u305f\u3068\u304d\u306b\u5373\u5ea7\u306b\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u8907\u96d1\u6a5f\u69cb\u3092\u4e8b\u524d\u306b\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002<\/li>\n<li>\u96fb\u529b\u6d88\u8cbb\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u308b\u306b\u306f\u3001\u30a2\u30d7\u30ea\u306e\u73fe\u5728\u306e\u30c7\u30fc\u30bf\u3068\u5c06\u6765\u306e\u30a8\u30f3\u30c8\u30ea\u3092\u542b\u3080\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n<li>\u3053\u306e\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u306b\u3088\u308a\u3001ClockKit\u306f\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u30bf\u30b9\u30af\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u306a\u304f\u3001\u81ea\u52d5\u7684\u306b\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u66f4\u65b0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n<h3>1.7 \u4e00\u62ec\u30ed\u30fc\u30c9\u30c7\u30fc\u30bf<\/h3>\n<ul>\n<li>\u5c06\u6765\u306eTimeline\u30a8\u30f3\u30c8\u30ea\u30fc\u306e\u30c7\u30fc\u30bf\u3092\u4e00\u62ec\u3057\u3066\u30ed\u30fc\u30c9\u3059\u308b\u306b\u306f\u3001\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u306e <a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationdatasource\/1628056-gettimelineenddate\">getTimelineEndDate(for:withHandler:)<\/a> \u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3057\u3066\u3001\u30cf\u30f3\u30c9\u30e9\u306b\u3042\u306a\u305f\u304c\u4f5c\u6210\u51fa\u6765\u308b\u6700\u5f8c\u306eTimeline\u30a8\u30f3\u30c8\u30ea\u30fc\u306e\u65e5\u4ed8\u3092\u6e21\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<li>\u4f8b\u3048\u3070\u3001\u30df\u30fc\u30c6\u30a3\u30f3\u30b0\u30a2\u30d7\u30ea\u306e\u5834\u5408\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u6700\u5f8c\u306b\u30df\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u884c\u3063\u305f\u65e5\u4ed8\u3092\u8fd4\u3059\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/li>\n<\/ul>\n<pre class=\"prettyprint\">func getTimelineEndDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -&gt; Void) {\n handler(myMeetings.last?.date)\n}<\/pre>\n<p>\u6b21\u306b\u3001\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u306e <a href=\"https:\/\/developer.apple.com\/documentation\/clockkit\/clkcomplicationdatasource\/1628094-gettimelineentries\">getTimelineEntries(for:after:limit:withHandler:)<\/a> \u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>2.\u5b9f\u969b\u306b\u8a66\u3059<\/h2>\n<p>API\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u6a2a\u65ad\u7684\u306b\u8aad\u307f\u3001\u307e\u3068\u3081\u306a\u304c\u3089\u96f0\u56f2\u6c17\u306f\u63b4\u3093\u3060\u306e\u3067\u52d5\u304b\u3057\u3066\u307f\u308b\u3002<\/p>\n<p>getComplicationDescriptors \u3067\u5b9a\u7fa9\u3057\u305f\u3001identifier: &#8220;complication\u201d\u3092\u3001getCurrentTimelineEntry \u5185\u90e8\u3067\u5224\u5b9a(complication.identifier)\u3057\u3066\u3042\u3052\u3066\u3001\u3055\u3089\u306b\u3001complication.family \u3067\u5206\u5c90\u3057\u3001.modularSmall\u306e\u6642\u306b\u8868\u793a\u3059\u308b\u5185\u5bb9\u3092\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint\">import ClockKit\n\n\nclass ComplicationController: NSObject, CLKComplicationDataSource {\n    \n    \/\/ MARK: - Complication Configuration\n\n    func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -&gt; Void) {\n        let descriptors = [\n            CLKComplicationDescriptor(identifier: \"complication\", displayName: \"HealthSample\", supportedFamilies: CLKComplicationFamily.allCases)\n            \/\/ Multiple complication support can be added here with more descriptors\n        ]\n        \n        \/\/ Call the handler with the currently supported complication descriptors\n        handler(descriptors)\n    }\n\n    \/\/ MARK: - Timeline Population\n    \n    func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -&gt; Void) {\n        \/\/ Call the handler with the current timeline entry\n        \n        switch complication.identifier {\n        case \"complication\":\n\n            switch complication.family {\n            case .circularSmall:\n                handler(nil)\n                return\n            case .modularSmall:\n                let img = CLKImageProvider(onePieceImage: UIImage(named: \"Complication\/Modular\")!)\n                \n                let text = CLKSimpleTextProvider(\n                    text: \"HealthSample\",\n                    shortText: \"70.0\")\n                \n                let template = CLKComplicationTemplateModularSmallStackImage(\n                    line1ImageProvider: img,\n                    line2TextProvider: text)\n        \n                let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template);\n                handler(entry)\n\n            case .modularLarge:\n                handler(nil)\n                return\n            default:\n                handler(nil)\n                return\n            }\n        default:\n            handler(nil)\n            return\n        }\n    }\n}\n<\/pre>\n<p>\u9069\u5f53\u306a\u753b\u50cf\u3092Assets\u306e\u3001\u4eca\u56de\u4f7f\u7528\u3059\u308bModular\u306b\u767b\u9332\u3059\u308b\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u304b\u3089\u547c\u3073\u51fa\u3059\u5834\u5408\u3001UIImage(named: &#8220;Complication\/Modular\u201d) \u3068\u306a\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/complication_assets.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"complication_assets.png\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/complication_assets.png\" alt=\"complication_assets\" width=\"826\" height=\"257\" border=\"0\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2022\/06\/11\/swift_watchos_complication_watchface_run_app\/\">\u524d\u56de\u6587\u5b57\u76e4\u306b\u8ffd\u52a0\u3057\u305f\u4f4d\u7f6e\u306e\u30a2\u30a4\u30b3\u30f3<\/a>\u304c\u3001\u4eca\u56de\u8ffd\u52a0\u3057\u305f\u753b\u50cf\u3068\u3001\u9069\u5f53\u306b\u5165\u308c\u305f\u30c6\u30ad\u30b9\u30c8\u306b\u7f6e\u304d\u63db\u308f\u3063\u305f\uff01\uff01<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/complication_icon.png.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"complication_icon.png.PNG\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/2022\/06\/complication_icon.png.png\" alt=\"complication_icon\" width=\"188\" height=\"229\" border=\"0\" \/><\/a><\/p>\n<p>OKOK\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u5b57\u76e4\u306b\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u30a2\u30a4\u30b3\u30f3\u3092\u8ffd\u52a0\u3057\u3001\u30a2\u30d7\u30ea\u3092\u8d77\u52d5\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3001\u30b3\u30f3\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3057\u3066\u307f\u308b\u3002 1.\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u4f5c\u6210\u3059\u308b \u30a2\u30d7\u30ea\u56fa\u6709\u306e\u30c7\u30fc\u30bf\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u307e\u3068\u3081\u3001\u305d\u306e\u30c6\u30f3\u30d7\u30ec\u30fc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1687,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[127,194,126],"tags":[196,130,195,129],"class_list":["post-1688","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swift","category-watchos","category-xcode","tag-complication","tag-swift","tag-watchos","tag-xcode"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1688","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1688"}],"version-history":[{"count":2,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1688\/revisions"}],"predecessor-version":[{"id":1691,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1688\/revisions\/1691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media\/1687"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}