{"id":1293,"date":"2020-12-11T15:47:01","date_gmt":"2020-12-11T07:47:01","guid":{"rendered":"http:\/\/123.57.164.21\/?p=1293"},"modified":"2020-12-11T15:47:01","modified_gmt":"2020-12-11T07:47:01","slug":"ios14-widget%e5%b0%8f%e7%bb%84%e4%bb%b6%e5%bc%80%e5%8f%91%e5%ae%9e%e8%b7%b54-%e7%94%a8%e6%88%b7%e5%b1%9e%e6%80%a7%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=1293","title":{"rendered":"iOS14 Widget\u5c0f\u7ec4\u4ef6\u5f00\u53d1\u5b9e\u8df54\u2014\u2014\u7528\u6237\u5c5e\u6027\u914d\u7f6e"},"content":{"rendered":"\n<p>\u8ba9\u6211\u5148\u5410\u69fd\u4e0b\uff0c\u8fd9\u73a9\u610f\u8ba9\u6211\u8e29\u4e86\u4e0d\u5c11\u5751\uff0c\u7f51\u4e0a\u7684\u4e00\u4e9b\u8d44\u6599\u4e5f\u90fd\u662f\u5728\u6b63\u5f0f\u7248\u51fa\u6765\u4e4b\u524d\u7684\uff0c\u5728\u6211\u5f00\u59cb\u6574\u8fd9\u4e2a\u7684\u65f6\u5019\uff0c\u633a\u5751\u7684\u3002<\/p>\n\n\n\n<p>\u8a00\u5f52\u6b63\u4f20\uff0c\u8fd8\u8bb0\u5f97\u5728\u7b2c\u4e00\u6b21\u521b\u5efa<code>Widget<\/code>\u7684\u65f6\u5019\uff0c\u6709\u4e00\u4e2a\u9009\u9879\u6211\u4eec\u6ca1\u6709\u52fe\u9009\uff0c<code>Include Configuration Intent<\/code>\u3002\u8fd9\u9009\u9879\u4e3b\u8981\u662f\u7528\u6765\u652f\u6301\u4f60\u81ea\u5b9a\u4e49\u4e00\u4e9b\u5c5e\u6027\u914d\u7f6e\uff08\u4f8b\u5982\u5929\u6c14\u7ec4\u4ef6\uff0c\u7528\u6237\u53ef\u4ee5\u9009\u62e9\u57ce\u5e02\uff0c\u80a1\u7968\u7ec4\u4ef6\uff0c\u7528\u6237\u53ef\u4ee5\u9009\u62e9\u4ee3\u7801\u7b49\uff09<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-11-1024x732.png\" alt=\"\" class=\"wp-image-1294\" width=\"510\" height=\"364\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-11-1024x732.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-11-300x214.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-11-768x549.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-11-830x593.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-11-230x164.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-11-350x250.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-11-480x343.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-11.png 1324w\" sizes=\"(max-width: 510px) 100vw, 510px\" \/><\/figure><\/div>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u8bd5\u7740\u91cd\u65b0\u521b\u5efa\u4e00\u4e2a<code>Widget<\/code>\uff0c\u5e76\u4e14\u52fe\u9009\u4e0a\uff0c\u7136\u540e\u5bf9\u6bd4\u4e0b<code>Xcode<\/code>\u751f\u6210\u7684\u4ee3\u7801\u5b9e\u73b0\u8ddf\u672a\u52fe\u9009\u7684\u4ee3\u7801\u5b9e\u73b0\u6709\u4ec0\u4e48\u533a\u522b\u3002<br>\u9996\u5148\u4f60\u4f1a\u53d1\u73b0\u5de6\u4fa7\u76ee\u5f55\u5217\u8868\u51fa\u73b0\u4e00\u4e2a\u540e\u7f00\u540d\u4e3a<code>.intentdefinition<\/code>\u7684\u6587\u4ef6\uff0c\u81f3\u4e8e\u91cc\u9762\u7684\u4e1c\u897f\u5148\u7565\u8fc7\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-12.png\" alt=\"\" class=\"wp-image-1295\" width=\"385\" height=\"468\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-12.png 702w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-12-247x300.png 247w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-12-230x280.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-12-350x426.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-12-480x584.png 480w\" sizes=\"(max-width: 385px) 100vw, 385px\" \/><\/figure><\/div>\n\n\n\n<p><strong>Provider<\/strong><br>\u65b0\u7684<code>Provider<\/code>\u73b0\u5728\u4e0d\u518d\u662f\u9075\u5b88<code>TimelineProvider<\/code>\uff0c\u800c\u662f<strong>\u9075\u5b88<code>IntentTimelineProvider<\/code><\/strong>\u534f\u8bae\uff0c\u5e76\u4e14\u5185\u90e8\u7684\u4e09\u4e2a<code>placeholder<\/code>\u3001<code>getSnapshot<\/code>\u3001<code>getTimeline<\/code>\u5fc5\u5b9e\u73b0\u65b9\u6cd5\u7684\u53c2\u6570\u4e5f\u591a\u589e\u52a0\u4e86\u4e00\u4e2a<code>ConfigurationIntent<\/code>\u3002<\/p>\n\n\n\n<p><strong>SimpleEntry<\/strong><br><code>SimpleEntry<\/code>\u4e5f\u589e\u52a0\u4e86\u4e00\u4e2a<code>ConfigurationIntent<\/code>\u7c7b\u578b\u7684\u53c2\u6570<\/p>\n\n\n\n<p><strong>Widget<\/strong><br><code>Widgetd<\/code>\u7684\u5185\u90e8body\u5b9e\u73b0\u7684\u914d\u7f6e\u65b9\u6cd5\u7531\u9759\u6001\u7684<code>StaticConfiguration<\/code>\u6362\u6210\u4e86\u52a8\u6001\u7684<code>IntentConfiguration<\/code><\/p>\n\n\n\n<p>\u53ef\u4ee5\u8bd5\u7740\u6dfb\u52a0\u7cfb\u7edfAPP\u7684\u5c0f\u7ec4\u4ef6\uff0c\u6bd4\u5982\u5929\u6c14\uff0c\u7136\u540e\u684c\u9762\u4e0a\u957f\u6309\uff0c\u4f1a\u51fa\u73b0\u4e86\u4e00\u4e2a\u7f16\u8f91\u5c0f\u7ec4\u4ef6\u7684\u9009\u9879\uff0c\u70b9\u51fb\u8fdb\u53bb\u53ef\u4ee5\u770b\u5230\u5141\u8bb8\u7528\u6237\u7f16\u8f91\u5f53\u524d\u4f4d\u7f6e\uff0c\u7528\u6765\u5c55\u793a\u4e0d\u540c\u5730\u65b9\u7684\u5929\u6c14\uff0c\u5177\u4f53\u622a\u56fe\u4e0d\u6574\u4e86\uff0c\u81ea\u5df1\u624b\u673a\u770b\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u73b0\u5728\u6211\u4eec\u5728<strong>\u5df2\u7ecf\u52fe\u9009\u4e86\u914d\u7f6e\u9009\u62e9<\/strong>\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u64cd\u4f5c\uff0c\u5b9e\u73b0\u4e00\u4e2a\u5c55\u793a\u4e00\u4e2a<code>Text<\/code>\u6587\u672c\u7684\u5c0f\u7ec4\u4ef6\uff0c\u901a\u8fc7\u7f16\u8f91\u8f93\u5165\u5185\u5bb9\uff0c\u5237\u65b0\u684c\u9762\u5c0f\u7ec4\u4ef6\u7684<code>Text<\/code>\u6587\u672c\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-14-509x1024.png\" alt=\"\" class=\"wp-image-1297\" width=\"281\" height=\"564\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-14-509x1024.png 509w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-14-149x300.png 149w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-14-230x462.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-14-350x704.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-14-480x965.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-14.png 588w\" sizes=\"(max-width: 281px) 100vw, 281px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-16-474x1024.png\" alt=\"\" class=\"wp-image-1299\" width=\"277\" height=\"597\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-16-474x1024.png 474w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-16-139x300.png 139w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-16-230x497.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-16-350x756.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-16-480x1037.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-16.png 600w\" sizes=\"(max-width: 277px) 100vw, 277px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-17-474x1024.png\" alt=\"\" class=\"wp-image-1300\" width=\"287\" height=\"619\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-17-474x1024.png 474w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-17-139x300.png 139w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-17-230x497.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-17-350x756.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-17-480x1037.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-17.png 602w\" sizes=\"(max-width: 287px) 100vw, 287px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fdb\u884c<code>.intentdefinition<\/code>\u7684\u9875\u9762\u914d\u7f6e<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-18-1024x606.png\" alt=\"\" class=\"wp-image-1301\" width=\"547\" height=\"323\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-18-1024x606.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-18-300x178.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-18-768x455.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-18-830x491.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-18-230x136.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-18-350x207.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-18-480x284.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-18.png 1338w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/><\/figure><\/div>\n\n\n\n<p>\u8bb0\u4f4f\u5de6\u4fa7<code>CUSTOM INTENTS<\/code>\u7684<code>Configuration<\/code>\u8fd9\u4e2a\u540d\u79f0\uff0cXcode\u4f1a\u6839\u636e\u8fd9\u4e2a\u540d\u79f0\uff0c\u81ea\u52a8\u751f\u6210\u4e00\u4e2a<code>ConfigurationIntent<\/code>\u7c7b\uff0c\u8fd9\u4e2a\u7c7b\u5c31\u662f\u63a5\u4e0b\u6765\u9700\u8981\u7528\u5230\u7684\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-19-1024x562.png\" alt=\"\" class=\"wp-image-1302\" width=\"540\" height=\"296\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-19-1024x562.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-19-300x165.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-19-768x421.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-19-830x455.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-19-230x126.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-19-350x192.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-19-480x263.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-19.png 1334w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/><\/figure><\/div>\n\n\n\n<p>\u518d\u56de\u5230<code>.intentdefinition<\/code>\u7684\u914d\u7f6e\u9875\u9762\uff0c\u5728\u4e0b\u9762\u7684\u5730\u65b9\u589e\u52a0\u4e00\u4e2a<code>title<\/code>\u5c5e\u6027\uff0c<code>String<\/code>\u7c7b\u578b\uff0c\u6ce8\u610f\u53f3\u8fb9\u7684\u56db\u4e2a\u9009\u9879\u53ea\u9700\u8981\u52fe\u9009\u7b2c2\u4e2a\uff0c\u6839\u636e\u8bf4\u660e\u5c31\u77e5\u9053\u8fd9\u4e2a\u9009\u9879\u662f\u5141\u8bb8\u7f16\u8f91\u7684\uff0c\u4f60\u53ef\u4ee5\u4e0d\u52fe\u9009\u8bd5\u8bd5\u6548\u679c\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-20-1024x780.png\" alt=\"\" class=\"wp-image-1303\" width=\"551\" height=\"419\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-20-1024x780.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-20-300x229.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-20-768x585.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-20-830x633.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-20-230x175.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-20-350x267.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-20-480x366.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-20.png 1328w\" sizes=\"(max-width: 551px) 100vw, 551px\" \/><\/figure><\/div>\n\n\n\n<p>\u56de\u5230\u4ee3\u7801\u5b9e\u73b0\u9875\u9762\uff0c\u6211\u4eec\u53ea\u8981\u4fee\u6539\u4e0b<code>WidgetEntryView<\/code>\u7684body\u91cc\u9762\u7684<code>Text<\/code>\u5185\u5bb9\uff0c\u4ece<code>entry<\/code>\u91cc\u9762\u83b7\u53d6\u5230<code>configuration<\/code>\u914d\u7f6e\u7684<code>title<\/code>\u5c5e\u6027\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct LLLLWidgetEntryView : View {\n    var entry: Provider.Entry\n\n    var body: some View {\n\/\/        Text(entry.date, style: .time)\n        Text(entry.configuration.title == nil ? \"\u6ca1\u6709\u503c\" : entry.configuration.title!)\n    }\n}<\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u8fd0\u884c\u8d77\u6765\uff0c\u4f53\u9a8c\u4e0b\u6548\u679c\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h6 class=\"wp-block-heading\">\u63a5\u4e0b\u6765\u8bf4\u6211\u78b0\u5230\u7684\u5751\uff01\uff01\uff01\uff01\uff01\uff01\u3002<\/h6>\n\n\n\n<p>\u4e0a\u9762\u90fd\u662f\u57fa\u4e8e\u4e00\u5f00\u59cb\u5c31\u52fe\u9009\u4e86<code>Include Configuration Intent<\/code>\u7684\u60c5\u51b5\u4e0b\uff0c<code>Xcode<\/code>\u9ed8\u8ba4\u751f\u6210\u7684\u6587\u4ef6\u3001\u4ee3\u7801\u3002<br>\u4e0b\u9762\u6765\u770b\u770b\u4e00\u5f00\u59cb\u6ca1\u52fe\u9009\uff0c\u540e\u671f\u5f00\u53d1\u9700\u6c42\u9700\u8981\u914d\u7f6e\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u4f55\u5904\u7406\u3002<\/p>\n\n\n\n<ul><li>\u83dc\u5355<code>File<\/code> -&gt;<code>New<\/code> -&gt;<code>File<\/code>\u7136\u540e\u627e\u5230<code>Siri Intent Definition File<\/code>\u4e4b\u540e\u6dfb\u52a0\u5230<code>WidgetExtension<\/code>\u4e2d\uff0c\u547d\u540d\u7684\u8bdd\uff0c\u5efa\u8bae\u53d6\u4e2a\u5408\u9002\u7684\u540d\u79f0\u3002<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u91cd\u8981\u7684\u4e8b\u60c5\u8bf4\u4e09\u904d\uff0c\u7bad\u5934\u90a3\u8fb9\u4e00\u5b9a\u8981\u52fe\u9009<\/h3>\n\n\n\n<p>\u4e0d\u77e5\u9053\u4e0d\u662f\u9ed8\u8ba4\u4e0d\u52fe\u9009\uff0c\u6211\u4e00\u5f00\u59cb\u6ca1\u6ce8\u610f\uff0c\u5bfc\u81f4\u540e\u9762\u4ee3\u7801\u91cc\u4e00\u76f4\u8054\u60f3\u4e0d\u51fa\u6765\u5b83\u81ea\u52a8\u751f\u6210\u7684\u90a3\u4e2a<code>swift<\/code>\u7c7b\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"543\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-22-1024x543.png\" alt=\"\" class=\"wp-image-1305\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-22-1024x543.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-22-300x159.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-22-768x407.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-22-830x440.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-22-230x122.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-22-350x186.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-22-480x255.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-22.png 1324w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u6dfb\u52a0<code>Intents<\/code>\uff0c\u547d\u540d\u5565\u7684\u53ef\u4ee5\u8ddf\u4e0a\u9762\u521b\u5efa\u7684\u547d\u540d\u4e00\u6837\uff0c\u597d\u8bb0\u554a\u3002<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2020\/12\/image-23-1024x483.png\" alt=\"\" class=\"wp-image-1306\" width=\"538\" height=\"253\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-23-1024x483.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-23-300x141.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-23-768x362.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-23-830x391.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-23-230x108.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-23-350x165.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-23-480x226.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/12\/image-23.png 1264w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u63a5\u4e0b\u6765\u7684\u8bbe\u7f6e\u5c31\u8ddf\u4e0a\u9762\u9ed8\u8ba4\u751f\u6210\u7684\u60c5\u51b5\u4e0b\u4e00\u6837\uff0c\u6dfb\u52a0\u5c5e\u6027\u3001\u8be5\u52fe\u9009\u7684\u52fe\u9009\u3002<\/li><li>\u4ee3\u7801\u90e8\u5206\u7684\u4fee\u6539\uff0c\u5c0f\u6280\u5de7\u5c31\u662f\u4f60\u8ddf\u7740\u9ed8\u8ba4\u751f\u6210\u7684\u90a3\u79cd\u6837\u5f0f\u7684\u4ee3\u7801\u5bf9\u7167\uff0c\u54ea\u91cc\u4e0d\u4e00\u6837\u5c31\u6539\u54ea\u91cc\u3002<\/li><\/ul>\n\n\n\n<p>\u5148\u4fee\u6539<code>Widget<\/code>\u7684\u914d\u7f6e\uff0c\u7531<code>StaticConfiguration<\/code>\u6539\u6210<code>IntentConfiguration<\/code>\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@main\nstruct MyWidget: Widget {\n    let kind: String = \"MyWidget\"\n    var body: some WidgetConfiguration {\n\/\/        StaticConfiguration(kind: kind, provider: Provider()) { entry in\n\/\/            MyWidgetEntryView(entry: entry)\n\/\/        }\n\/\/        .configurationDisplayName(\"My Widget\")\n\/\/        .description(\"This is an example widget.\")\n        \n        IntentConfiguration(kind: kind, intent: MyIntentConfigurationIntent.self, provider: Provider()) { entry in\n            MyWidgetEntryView(entry: entry)\n        }\n        .configurationDisplayName(\"My Widget\")\n        .description(\"This is an example widget.\")\n    }\n}<\/pre>\n\n\n\n<p><code>SimpleEntry<\/code>\u589e\u52a0<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct SimpleEntry: TimelineEntry {\n    let date: Date\n    let configuration: MyIntentConfigurationIntent\n}<\/pre>\n\n\n\n<p><code>Provider<\/code>\u7684\u7ee7\u627f\u6539\u6210<code>IntentTimelineProvider<\/code><br>\u5f00\u5934\u7684\u4e24\u4e2a<code>typealias<\/code>\u5fc5\u987b\u5b9e\u73b0\uff0c\u4e0d\u5b9e\u73b0\u6211\u8fd9\u91cc\u4f1a\u62a5\u9519\uff0c\u6682\u65f6\u6ca1\u6574\u660e\u767d\uff0c\u56e0\u4e3a\u7f51\u4e0a\u6709\u4e9b\u6587\u7ae0\u6ca1\u6709\u5b9e\u73b0\u4e5f\u53ef\u4ee5\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct Provider: IntentTimelineProvider {\n    typealias Entry = SimpleEntry\n    typealias Intent = MyIntentConfigurationIntent\n    \n    func placeholder(in context: Context) -> SimpleEntry {\n        SimpleEntry(date: Date(), configuration: MyIntentConfigurationIntent())\n    }\n    \n    func getSnapshot(for configuration: MyIntentConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> Void) {\n        let entry = SimpleEntry(date: Date(), configuration: configuration)\n        completion(entry)\n    }\n    \n    func getTimeline(for configuration: MyIntentConfigurationIntent, in context: Context, completion: @escaping (Timeline&lt;SimpleEntry>) -> Void) {\n            var entries: [SimpleEntry] = []\n            let currentDate = Date()\n            for hourOffset in 0 ..&lt; 5 {\n                let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!\n                let entry = SimpleEntry(date: entryDate, configuration: configuration)\n                entries.append(entry)\n            }\n\n            let timeline = Timeline(entries: entries, policy: .atEnd)\n            completion(timeline)\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u53c2\u8003\u8d44\u6599<\/h4>\n\n\n\n<p><a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fdeveloper.apple.com%2Fdocumentation%2Fwidgetkit%2Fcreating-a-widget-extension\" target=\"_blank\" rel=\"noreferrer noopener\">creating-a-widget-extension<\/a><br><a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fswiftrocks.com%2Fios-14-widget-tutorial-mini-apps\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/swiftrocks.com<\/a><br><a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fdeveloper.apple.com%2Fdocumentation%2Fwidgetkit%2Fintentconfiguration\" target=\"_blank\" rel=\"noreferrer noopener\">IntentConfiguration<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8ba9\u6211\u5148\u5410\u69fd\u4e0b\uff0c\u8fd9\u73a9\u610f\u8ba9\u6211\u8e29\u4e86\u4e0d\u5c11\u5751\uff0c\u7f51\u4e0a\u7684\u4e00\u4e9b\u8d44\u6599\u4e5f\u90fd\u662f\u5728\u6b63\u5f0f\u7248\u51fa\u6765\u4e4b\u524d\u7684\uff0c\u5728\u6211\u5f00\u59cb\u6574\u8fd9\u4e2a\u7684\u65f6\u5019\uff0c\u633a\u5751\u7684\u3002 \u8a00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1293"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1293"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1293\/revisions"}],"predecessor-version":[{"id":1308,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1293\/revisions\/1308"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}