{"id":4876,"date":"2022-01-14T22:25:02","date_gmt":"2022-01-14T14:25:02","guid":{"rendered":"http:\/\/123.57.164.21\/?p=4876"},"modified":"2022-01-14T22:25:02","modified_gmt":"2022-01-14T14:25:02","slug":"swiftui-watchos-%e4%b8%80%e4%ba%9btips","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=4876","title":{"rendered":"SwiftUI watchOS \u4e00\u4e9bTips"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">1.WatchOS View\u5982\u4f55\u5168\u5c4f\u3002<\/h5>\n\n\n\n<p>\u5f53\u6211\u4eec\u5f00\u53d1WatchOS App\u65f6\uff0c\u4f1a\u53d1\u73b0WatchOS Status Bar\u5360\u7528Header\u533a\u57df\uff0c\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u628aApp\u5168\u5c4f\u5e55\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-17.png\" alt=\"\" class=\"wp-image-4877\" width=\"243\" height=\"296\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-17.png 448w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-17-246x300.png 246w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-17-230x280.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-17-350x427.png 350w\" sizes=\"(max-width: 243px) 100vw, 243px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u7528.edgesIgnoringSafeArea(.all)<\/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 XXXXXXXXApp: App {\n    \n    @WKExtensionDelegateAdaptor(ExtensionDelegate.self) var extensionDelegate\n    \n    @Environment(\\.scenePhase) var scenePhase\n    @SceneBuilder var body: some Scene {\n        WindowGroup {\n            \/\/ !!!Remove any NavigationView and use edgesIgnoringSafeArea and it works!!!\n            \/\/ NavigationView {\n                ContentView().edgesIgnoringSafeArea(.all)\n            \/\/ }\n        }.onChange(of: scenePhase) { newScenePhase in\n            switch newScenePhase {\n            case .active:\n                print(\"active\")\n            case .inactive:\n                print(\"inactive\")\n            case .background:\n                print(\"background\")\n            @unknown default:\n                print(\"default\")\n            }\n        }\n\n        WKNotificationScene(controller: NotificationController.self, category: \"myCategory\")\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-18.png\" alt=\"\" class=\"wp-image-4879\" width=\"224\" height=\"271\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-18.png 422w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-18-248x300.png 248w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-18-230x278.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-18-350x423.png 350w\" sizes=\"(max-width: 224px) 100vw, 224px\" \/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n","protected":false},"excerpt":{"rendered":"<p>1.WatchOS View\u5982\u4f55\u5168\u5c4f\u3002 \u5f53\u6211\u4eec\u5f00\u53d1WatchOS App\u65f6\uff0c\u4f1a\u53d1\u73b0WatchOS Status [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/4876"}],"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=4876"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/4876\/revisions"}],"predecessor-version":[{"id":4880,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/4876\/revisions\/4880"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}