{"id":2133,"date":"2021-03-29T09:38:22","date_gmt":"2021-03-29T01:38:22","guid":{"rendered":"http:\/\/123.57.164.21\/?p=2133"},"modified":"2021-03-29T09:38:22","modified_gmt":"2021-03-29T01:38:22","slug":"swift%e9%a1%b9%e7%9b%ae%e4%b8%ad%e6%b7%bb%e5%8a%a0ios14-widget%e5%b0%8f%e7%bb%84%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=2133","title":{"rendered":"swift\u9879\u76ee\u4e2d\u6dfb\u52a0iOS14 Widget\u5c0f\u7ec4\u4ef6"},"content":{"rendered":"\n<p>iOS14\u53d1\u5e03\u540e\u65b0\u589e\u52a0\u4e86\u5f88\u591a\u7684\u529f\u80fd\uff08\u5c4f\u5e55\u5c0f\u7ec4\u4ef6widget\u3001App Library \u9875\u9762\u3001\u300cApp Clips\u300d\u82f9\u679c\u7248\u7684\u300c\u5c0f\u7a0b\u5e8f\u300d&#8230;&#8230;\uff09\uff0c\u53ef\u80fd\u5bf9\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u6700\u5173\u6ce8\u7684\u65b0\u529f\u80fd\u5c31\u662fwidget\u5c0f\u7ec4\u4ef6\u548cApp Clips\u3002\u4eca\u5929\u4e3b\u8981\u6765\u8bf4\u8bf4\u5982\u4f55\u5728\u81ea\u5df1\u7684\u9879\u76ee\u4e2d\u6dfb\u52a0widget\u5c0f\u7ec4\u4ef6\u3002<\/p>\n\n\n\n<p>\u9879\u76ee\u4e2d\u6dfb\u52a0Widget\u6211\u662f\u501f\u9274\u4e86\u8fd9\u4e2a\u4f5c\u8005\u7684\u6587\u7ae0\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jianshu.com\/p\/55dce7a524f5\" target=\"_blank\">https:\/\/www.jianshu.com\/p\/55dce7a524f5<\/a><\/p>\n\n\n\n<ul><li>\u6253\u5f00Xcode -&gt; File -&gt; New -&gt; Target\u83dc\u5355\u8def\u5f84\u627e\u5230 Widget Extension\uff0c\u53cc\u51fb\u521b\u5efa<\/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\/2021\/03\/image-50-1024x727.png\" alt=\"\" class=\"wp-image-2134\" width=\"606\" height=\"430\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-50-1024x727.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-50-300x213.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-50-768x545.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-50-830x589.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-50-230x163.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-50-350x249.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-50-480x341.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-50.png 1318w\" sizes=\"(max-width: 606px) 100vw, 606px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u8f93\u5165Product Name\uff08\u6211\u7528\u7684\u662fTestWidget\uff09\u5176\u4ed6\u7684\u90fd\u9ed8\u8ba4\u9009\u62e9\uff0c\u70b9\u51fbFinish\uff01<\/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\/2021\/03\/image-51-988x1024.png\" alt=\"\" class=\"wp-image-2136\" width=\"396\" height=\"410\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-51-988x1024.png 988w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-51-290x300.png 290w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-51-768x796.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-51-830x860.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-51-230x238.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-51-350x363.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-51-480x497.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-51.png 1324w\" sizes=\"(max-width: 396px) 100vw, 396px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u7f16\u8bd1\u4e00\u4e0b\u6ca1\u95ee\u9898\u540e\uff0c\u8fd0\u884c\u5728\u6a21\u62df\u5668\u4e0a\u770b\u4e0bXcode\u4e3a\u6211\u4eec\u751f\u6210\u7684\u9ed8\u8ba4\u6548\u679c\uff08\u9ed8\u8ba4\u4e09\u4e2a\u6837\u5f0f\uff09\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\/2021\/03\/image-52-933x1024.png\" alt=\"\" class=\"wp-image-2137\" width=\"368\" height=\"403\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-52-933x1024.png 933w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-52-273x300.png 273w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-52-768x843.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-52-830x911.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-52-230x252.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-52-350x384.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-52-480x527.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-52.png 1186w\" sizes=\"(max-width: 368px) 100vw, 368px\" \/><\/figure><\/div>\n\n\n\n<p>\u770b\u4e00\u4e0bXcode\u751f\u6210\u7684\u9ed8\u8ba4\u7684Widget\u6e90\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Provider\uff1a\u4e3a\u5c0f\u7ec4\u4ef6\u5c55\u793a\u63d0\u4f9b\u4e00\u5207\u5fc5\u8981\u4fe1\u606f\u7684\u7ed3\u6784\u4f53\uff0c\u5b9e\u73b0TimelineProvider\u534f\u8bae\nplaceholder\uff1a\u63d0\u4f9b\u4e00\u4e2a\u9ed8\u8ba4\u7684\u89c6\u56fe\uff0c\u5f53\u7f51\u7edc\u6570\u636e\u8bf7\u6c42\u5931\u8d25\u6216\u8005\u5176\u4ed6\u4e00\u4e9b\u5f02\u5e38\u7684\u65f6\u5019\uff0c\u7528\u4e8e\u5c55\u793a\ngetSnapshot\uff1a\u4e3a\u4e86\u5728\u5c0f\u90e8\u4ef6\u5e93\u4e2d\u663e\u793a\u5c0f\u90e8\u4ef6\uff0cWidgetKit\u8981\u6c42\u63d0\u4f9b\u8005\u63d0\u4f9b\u9884\u89c8\u5feb\u7167\uff0c\u5728\u7ec4\u4ef6\u7684\u6dfb\u52a0\u9875\u9762\u53ef\u4ee5\u770b\u5230\u6548\u679c\ngetTimeline\uff1a\u5728\u8fd9\u4e2a\u65b9\u6cd5\u5185\u53ef\u4ee5\u8fdb\u884c\u7f51\u7edc\u8bf7\u6c42\uff0c\u62ff\u5230\u7684\u6570\u636e\u4fdd\u5b58\u5728\u5bf9\u5e94\u7684entry\u4e2d\uff0c\u8c03\u7528completion\u4e4b\u540e\u4f1a\u5230\u5237\u65b0\u5c0f\u7ec4\u4ef6<\/pre>\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: TimelineProvider {\n    func placeholder(in context: Context) -> SimpleEntry {\n        SimpleEntry(date: Date())\n    }\n\n    func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {\n        let entry = SimpleEntry(date: Date())\n        completion(entry)\n    }\n\n    func getTimeline(in context: Context, completion: @escaping (Timeline&lt;Entry>) -> ()) {\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)\n            entries.append(entry)\n        }\n\n        let timeline = Timeline(entries: entries, policy: .atEnd)\n        completion(timeline)\n    }\n}<\/pre>\n\n\n\n<p>\u5b9e\u73b0TimelineEntry\u534f\u8bae\uff0c\u4fdd\u5b58\u6240\u9700\u8981\u7684\u6570\u636e<\/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}<\/pre>\n\n\n\n<p>\u7528\u6765\u5c55\u793a\u7684\u89c6\u56feView\uff0c\u53ef\u4ee5\u8fdb\u884c\u81ea\u5df1\u60f3\u8981\u7684\u754c\u9762\u642d\u5efa<\/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 TestWidgetEntryView : View {\n    var entry: Provider.Entry\n    var body: some View {\n        Text(entry.date, style: .time)\n    }\n}\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">@main struct TestWidget: Widget\n@main\uff1a\u4ee3\u8868\u7740Widget\u7684\u4e3b\u5165\u53e3\uff0c\u7cfb\u7edf\u4ece\u8fd9\u91cc\u52a0\u8f7d\nkind\uff1a\u662fWidget\u7684\u552f\u4e00\u6807\u8bc6\nStaticConfiguration\uff1a\u521d\u59cb\u5316\u914d\u7f6e\u4ee3\u7801\nconfigurationDisplayName\uff1a\u6dfb\u52a0\u7f16\u8f91\u754c\u9762\u5c55\u793a\u7684\u6807\u9898\ndescription\uff1a\u6dfb\u52a0\u7f16\u8f91\u754c\u9762\u5c55\u793a\u7684\u63cf\u8ff0\u5185\u5bb9\nsupportedFamilies\u8fd9\u91cc\u53ef\u4ee5\u9650\u5236\u8981\u63d0\u4f9b\u4e09\u4e2a\u6837\u5f0f\u4e2d\u7684\u54ea\u51e0\u4e2a\n<\/pre>\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 TestWidget: Widget {\n    let kind: String = \"TestWidget\"\n\n    var body: some WidgetConfiguration {\n        StaticConfiguration(kind: kind, provider: Provider()) { entry in\n            TestWidgetEntryView(entry: entry)\n        }\n        .configurationDisplayName(\"My Widget\")\n        .description(\"This is an example widget.\")\n        \/\/supportedFamilies\u4e0d\u8bbe\u7f6e\u7684\u8bdd\u9ed8\u8ba4\u4e09\u4e2a\u6837\u5f0f\u90fd\u5b9e\u73b0\n        .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])\n    }\n}\n<\/pre>\n\n\n\n<p>\u5176\u5b9e\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2a\u6837\u5f0f\uff0c\u4f46\u662f\u4e0d\u53d8\u7684\u5c31\u662f\u56fa\u5b9a\u7684\u4e09\u4e2a\u6837\u5f0f\uff08[.systemSmall, .systemMedium, .systemLarge]\uff09<br>\u7531\u4e8e\u6211\u662f\u5728\u6211\u7684swift+OC\u9879\u76ee\u4e2d\u6dfb\u52a0\u7684\uff0c\u6240\u4ee5\u5bf9swiftUI\u8fd8\u4e0d\u592a\u719f\u6089\uff08widget\u5fc5\u987b\u8981\u7528swiftUI\u5b9e\u73b0\uff09,\u6240\u4ee5\u53ea\u80fd\u7b80\u5355\u7684\u5b9e\u73b0\u4e00\u4e0b\u529f\u80fd\uff08\u592a\u590d\u6742\u7684UI\u6837\u5f0f\u8fd8\u641e\u4e0d\u5b9a\uff0c\u7b49swiftUI\u719f\u6089\u540e\u518d\u6298\u817e\u5427\uff09\uff0c\u4e3a\u4e86\u7b80\u5355\u65b9\u4fbf\u4e00\u70b9 \u6211\u81ea\u5b9a\u4e49\u7684\u6837\u5f0f\u5c31\u4e00\u4e2a.systemMedium<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u4e0b\u9762\u8fd9\u4e2a\u662f\u6211\u5728\u81ea\u5df1\u7684\u9879\u76ee\u4e2d\u6dfb\u52a0\u7684<\/h5>\n\n\n\n<p>wishesWidget.swift<\/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=\"\">import WidgetKit\nimport SwiftUI\nimport Intents\n\nstruct wishesModel {\n    let title: String \/\/\u6807\u9898\n    let content: String \/\/ \u5185\u5bb9\n}\n\nstruct wishesRequest {\n    \n    static func request(completion: @escaping (Result&lt;wishesModel, Error>) -> Void) {\n        let url = URL(string:\"\u81ea\u5df1\u7684url\u94fe\u63a5\u5730\u5740\")\n        guard let requestUrl = url else { fatalError() }\n        var request = URLRequest(url: requestUrl)\n        request.httpMethod = \"POST\"\n        let postString = \"\u81ea\u5df1\u7684\u53c2\u6570\u503c\"\n        request.httpBody = postString.data(using: String.Encoding.utf8)\n        let task = URLSession.shared.dataTask(with: request) { (data, response, error) in  \n            guard error == nil else {\n                completion(.failure(error!))\n                return\n            }\n            if let data = data, let dataString = String(data: data, encoding: .utf8) {\n                let model = modelFromJson(fromData: data)\n                completion(.success(model))\n            }\n        }\n        task.resume()\n    }\n    \n    static func modelFromJson(fromData data: Data) -> wishesModel {\n        let json = try! JSONSerialization.jsonObject(with: data, options: []) as! [String: Any]\n        guard let data = json[\"data\"] as? [String: Any] else {\n            return wishesModel(title:NSLocalizedString(\"sq_send_world_title\", comment: \"\"),content: NSLocalizedString(\"sq_req_fail\", comment: \"\"))\n        }\n        let title = data[\"title\"] as! String\n        let content = data[\"content\"] as! String\n        return wishesModel(title: title, content: content)\n    }\n}\n\nstruct wishesProvider: IntentTimelineProvider {\n    func placeholder(in context: Context) -> wishesEntry {\n        let model = wishesModel(title: NSLocalizedString(\"sq_send_world_title\", comment: \"\"), content: NSLocalizedString(\"sq_default_des\", comment: \"\"))\n        return wishesEntry(date: Date(), item: model, configuration: ConfigurationIntent())\n    }\n    \n    func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (wishesEntry) -> ()) {\n        let model = wishesModel(title: NSLocalizedString(\"sq_send_world_title\", comment: \"\"), content: NSLocalizedString(\"sq_default_des\", comment: \"\"))\n        let entry = wishesEntry(date: Date(), item: model, configuration: configuration)\n        completion(entry)\n    }\n    \n    func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline&lt;wishesEntry>) -> ()) {\n        let currentDate = Date()\n        \/\/ \u4e0b\u4e00\u6b21\u66f4\u65b0\u95f4\u9694\u4ee5\u5c0f\u65f6\u4e3a\u5355\u4f4d\uff0c\u95f4\u96941\u5c0f\u65f6\u8bf7\u6c42\u4e00\u6b21\u65b0\u7684\u6570\u636e\n        let updateDate = Calendar.current.date(byAdding: .hour, value: 1, to: currentDate)\n        wishesRequest.request { result in\n            let model: wishesModel\n            if case .success(let response) = result {\n                model = response\n            } else {\n                model = wishesModel(title: NSLocalizedString(\"sq_send_world_title\", comment: \"\"), content: NSLocalizedString(\"sq_req_fail\", comment: \"\"))\n            }\n            let entry = wishesEntry(date: updateDate!, item: model, configuration: configuration)\n            let timeline = Timeline(entries: [entry], policy: .after(updateDate!))\n            completion(timeline)\n        }\n    }\n}\n\nstruct wishesEntry: TimelineEntry {\n    let date: Date\n    let item: wishesModel \n    let configuration: ConfigurationIntent\n}\n\nstruct wishesWidgetEntryView : View {\n\n    var entry: wishesEntry\n  \n    var body: some View {\n        VStack(alignment: .leading, spacing: 0) {\n            HStack(alignment: .lastTextBaseline){\n                Text(entry.item.title)\n                    .font(.title2)\n                    .bold()\n                Spacer()\n                VStack(alignment: .trailing){\n                    Image(\"item_logo_icon\")\n                        .resizable()\n                        .frame(width: 30, height: 30, alignment: .center)\n                }\n            }\n            Spacer()\n            Text(entry.item.content)\n            .font(.system(size: 13))\n            .bold()\n            Spacer()\n        }\n        .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .leading)\n        .padding()\n        \/\/widget\u80cc\u666f\u56fe\u7247\n        .background(\n            Image(\"item_bg_icon\")\n                .resizable()\n                .scaledToFill()\n        )\n        .widgetURL(URL(string: \"url:\/\/123\"))\/\/\u83b7\u53d6\u70b9\u51fb\u6807\u8bb0 \u9700\u8981\u5728SceneDelegate\u91cc\u9762\u5b9e\u73b0\u8df3\u8f6c\u5904\u7406\uff0c\u56e0\u4e3aiOS13\u540e\uff0cAPP\u7684UI\u751f\u547d\u5468\u671f\u4ea4\u7531SceneDelegate\u7ba1\u7406\n        \/*\n         func scene(_ scene: UIScene, openURLContexts URLContexts: Set&lt;UIOpenURLContext>) {\n         for context in URLContexts {\n         print(context.url) \/\/\u83b7\u53d6widget\u70b9\u51fb\u6807\u8bb0 url:\/\/123\n         }\n         }\n         *\/\n\n         \/*\u6ce8\u610f\u26a0\ufe0f\uff1a\u7531\u4e8e\u6211\u7684\u9879\u76ee\u662fswift+OC \u6240\u4ee5\uff0c\u70b9\u51fbwidget\u63a7\u4ef6\u6253\u5f00\u54cd\u5e94\u5728AppDelegate \u4e2d\uff0c\n            func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {\n              if url.relativeString == \"url:\/\/123\" {\n                  \/\/TODO: \n\n                    return true\n                }\n            }\n          *\/\n    }\n}\n\n\/\/systemMedium \u4e2d\u6837\u5f0f\nstruct wishesWidget: Widget {\n    let kind: String = \"wishesWidget\"\n    \n    var body: some WidgetConfiguration {\n        IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: wishesProvider()) { entry in\n            wishesWidgetEntryView(entry: entry)\n        }\n        .configurationDisplayName(LocalizedStringKey(\"sq_title_widget\"))\n        .description(LocalizedStringKey(\"sq_intro_widget\"))\n        .supportedFamilies([.systemMedium])\/\/\u6211\u53ea\u9700\u8981\u4e00\u4e2a\u4e2d\u6837\u5f0f\u6240\u4ee5\u8fd9\u4e2a\u4f4d\u7f6e\u653e\u7f6e\u4e86\u4e00\u4e2a.systemMedium\uff0c\u5982\u679c\u9700\u8981\u591a\u4e2a\u6837\u5f0f\u53ef\u4ee5\u4ece\u8fd9\u4e09\u4e2a\u6837\u5f0f\uff08[.systemSmall, .systemMedium, .systemLarge]\uff09\u91cc\u9762\u9009\u62e9\uff0c\u4e5f\u53ef\u4ee5\u91cd\u590d\u4f7f\u7528\u5c5e\u6027\u503c\uff0c\u5c55\u793a\u591a\u4e2a\u6837\u5f0f\n    }\n}<\/pre>\n\n\n\n<p>wwsqWidget.swift\u6dfb\u52a0MyWidgetBundle\uff0c\u5173\u4e8e\u8fd9\u4e2aMyWidgetBundle\u540d\u5b57\u5e94\u8be5\u53ef\u4ee5\u968f\u610f\u4e3b\u8981\u662f@main\u4e3b\u5165\u53e3\uff08\u5982\u679c\u4f60\u662f\u7528\u4e0a\u9762\u7684\u6b65\u9aa4\u7684\u8bdd\u662f\u8fd9\u4e2a\u6587\u4ef6TestWidget.swift\uff09<em><\/em><\/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 MyWidgetBundle: WidgetBundle {\n    @WidgetBundleBuilder\n    var body: some Widget {\n        wishesWidget()\/\/\u5bc4\u8bed\u7ec4\u4ef6\n    }\n}\n<\/pre>\n\n\n\n<p>\u8fd9\u662f\u6211\u9879\u76ee\u4e2d\u6dfb\u52a0\u7684\u6587\u4ef6\u76ee\u5f55\uff08\u7531\u4e8e\u8fd9\u662f\u516c\u53f8\u7684\u9879\u76ee\uff0c\u8d34\u56fe\u7684\u8bdd\u9700\u8981\u6253\u7801\uff5e\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\/2021\/03\/image-54-1024x530.png\" alt=\"\" class=\"wp-image-2142\" width=\"581\" height=\"300\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-54-1024x530.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-54-300x155.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-54-768x398.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-54-830x430.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-54-230x119.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-54-350x181.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-54-480x248.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-54.png 1306w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><\/figure><\/div>\n\n\n\n<p>\u6700\u540e\u5728\u771f\u673a\u4e0a\u7684\u6548\u679c\uff1a<\/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\/2021\/03\/image-57-934x1024.png\" alt=\"\" class=\"wp-image-2149\" width=\"471\" height=\"515\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-57-934x1024.png 934w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-57-273x300.png 273w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-57-768x842.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-57-830x910.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-57-230x252.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/03\/image-57-350x384.png 350w\" sizes=\"(max-width: 471px) 100vw, 471px\" \/><\/figure><\/div>\n\n\n\n<p>End\uff1a\u5176\u5b9e\u5173\u4e8e\u9879\u76ee\uff08swift\u6216oc\u6216swift\u548coc\u6df7\u5408\u9879\u76ee\uff09\u4e2d\u6dfb\u52a0widget\u9879\u76ee\u8fd8\u6709\u5f88\u591a\u95ee\u9898\uff0c\u6bd4\u5982\u8bf4\u5982\u4f55\u5b9e\u73b0widget\u9879\u76ee\u4e2dLocalizable.strings\u591a\u8bed\u8a00\u672c\u5730\u5316\uff1f\u5982\u679c\u662fswiftUI\u5e94\u8be5\u53ef\u4ee5\u5168\u5c40\u8bbf\u95ee\u5230Localizable.strings\uff0c\u4f46\u662f\u4e0d\u662f\u7684\u8bdd\u9700\u8981\u5355\u72ec\u65b0\u5efaLocalizable.strings\uff0c\u800c\u4e14\u8fd8\u53d1\u73b0widget\uff08swiftUI\u5982\u4f55\u8bbf\u95ee\u83b7\u53d6swift\u9879\u76ee\u4e2d\u7684\u65b9\u6cd5\uff09\u65e0\u6cd5\u8bbf\u95eeswift\u9879\u76ee\u4e2d\u7684\u6587\u4ef6\u548c\u65b9\u6cd5.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>iOS14\u53d1\u5e03\u540e\u65b0\u589e\u52a0\u4e86\u5f88\u591a\u7684\u529f\u80fd\uff08\u5c4f\u5e55\u5c0f\u7ec4\u4ef6widget\u3001App Library \u9875\u9762\u3001\u300cApp Clips [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,5],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2133"}],"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=2133"}],"version-history":[{"count":10,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2133\/revisions"}],"predecessor-version":[{"id":2152,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2133\/revisions\/2152"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}