{"id":1582,"date":"2021-03-15T16:01:03","date_gmt":"2021-03-15T07:01:03","guid":{"rendered":"http:\/\/hirlab.net\/nblog\/?p=1582"},"modified":"2021-03-31T13:11:37","modified_gmt":"2021-03-31T04:11:37","slug":"%e3%80%90%e7%ac%ac5%e5%9b%9e%e3%80%91%e6%97%a5%e6%9c%ac%e8%aa%9e%e7%89%88swiftui%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab%e3%80%90%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7","status":"publish","type":"post","link":"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/","title":{"rendered":"\u3010\u7b2c5\u56de\u3011\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3010\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3011"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_11 counter-hierarchy counter-decimal ez-toc-light-blue\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u30b3\u30f3\u30c6\u30f3\u30c4<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#%E6%97%A5%E6%9C%AC%E8%AA%9E%E7%89%88SwiftUI%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#%E7%AC%AC5%E5%9B%9E%EF%BC%9A%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%93%E3%83%A5%E3%83%BC%E3%81%A8%E9%81%B7%E7%A7%BB\" title=\"\u7b2c5\u56de\uff1a\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30d3\u30e5\u30fc\u3068\u9077\u79fb\">\u7b2c5\u56de\uff1a\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30d3\u30e5\u30fc\u3068\u9077\u79fb<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#Step_1_%E3%83%8F%E3%82%A4%E3%82%AD%E3%83%B3%E3%82%B0%E3%83%A2%E3%83%87%E3%83%AB%E3%82%92%E4%BD%9C%E3%82%8B\" title=\"Step 1. \u30cf\u30a4\u30ad\u30f3\u30b0\u30e2\u30c7\u30eb\u3092\u4f5c\u308b\">Step 1. \u30cf\u30a4\u30ad\u30f3\u30b0\u30e2\u30c7\u30eb\u3092\u4f5c\u308b<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#Step_2_%E5%80%8B%E5%88%A5%E3%83%93%E3%83%A5%E3%83%BC%E3%81%B8%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B\" title=\"Step 2. \u500b\u5225\u30d3\u30e5\u30fc\u3078\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3066\u307f\u308b\">Step 2. \u500b\u5225\u30d3\u30e5\u30fc\u3078\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3066\u307f\u308b<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#Step_3_HikeView%E3%82%92%E4%BD%9C%E3%82%8B\" title=\"Step 3. HikeView\u3092\u4f5c\u308b\">Step 3. HikeView\u3092\u4f5c\u308b<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#Step_4_%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E8%AA%BF%E6%95%B4%E3%81%99%E3%82%8B\" title=\"Step 4. \u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8abf\u6574\u3059\u308b\">Step 4. \u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8abf\u6574\u3059\u308b<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#Step_5_%E5%87%9D%E3%81%A3%E3%81%9F%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E8%A8%AD%E5%AE%9A\" title=\"Step 5. \u51dd\u3063\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\">Step 5. \u51dd\u3063\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#Step_X_%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%82%92%E6%95%B4%E7%90%86%E3%81%99%E3%82%8B\" title=\"Step X. \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u6574\u7406\u3059\u308b\">Step X. \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u6574\u7406\u3059\u308b<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1582\/#%E7%AC%AC5%E5%9B%9E%EF%BC%9A%E3%81%8A%E3%82%8F%E3%82%8A%E3%81%AB\" title=\"\u7b2c5\u56de\uff1a\u304a\u308f\u308a\u306b\">\u7b2c5\u56de\uff1a\u304a\u308f\u308a\u306b<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E6%97%A5%E6%9C%AC%E8%AA%9E%E7%89%88SwiftUI%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB\"><\/span>\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1379\" src=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/0.png\" alt=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\" width=\"1200\" height=\"624\" srcset=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/0.png 1200w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/0-300x156.png 300w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/0-768x399.png 768w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/0-1024x532.png 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>\u672c\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306f\uff0c<a href=\"https:\/\/developer.apple.com\/tutorials\/swiftui\/\" target=\"_blank\" rel=\"noopener noreferrer\">Apple\u304c\u63b2\u8f09\u3057\u3066\u3044\u308b\u516c\u5f0f\u306eSwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<\/a>\u3092\u300c\u65e5\u672c\u8a9e\u3067\u300d\u305d\u3057\u3066\u300c\u8a73\u7d30\u306b\u300d\u89e3\u8aac\u3057\u76f4\u3059\u3053\u3068\u3092\u76ee\u7684\u3068\u3057\u305f\u8a18\u4e8b\u3067\u3059\uff0e<\/p>\n<p>\u3053\u306e\u624b\u306e\u8a18\u4e8b\u306f\uff0c\u4ed6\u306b\u3082\u4f3c\u305f\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u304c\uff0c\u5168\u3066\u3092\u7db2\u7f85\u3057\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u304f\uff0c\u90e8\u5206\u7684\u306b\u89e3\u8aac\u3057\u3066\u3044\u308b\u8a18\u4e8b\u304c\u591a\u6570\u3067\u3059\uff0e<\/p>\n<p>\u305d\u3053\u3067\uff0cSwiftUI\u3092\u4f7f\u3063\u3066\u30a2\u30d7\u30ea\u958b\u767a\u3092\u3057\u305f\u3044\u65b9\u3005\u306e\u305f\u3081\u306b\uff0c\u305d\u3057\u3066\u52c9\u5f37\u3057\u3066\u3044\u308b\u81ea\u5206\u81ea\u8eab\u306e\u305f\u3081\u306b\uff0c<strong>\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u5b8c\u5168\u7248<\/strong>\u3092\u66f8\u304d\u307e\u3059\uff0e<\/p>\n<p>\u306a\u304a\uff0c\u672c\u8a18\u4e8b\u306e\u96e3\u6613\u5ea6\u3068\u3057\u3066\u306f\uff0c\u521d\u7d1a\u8005\u3082\u898b\u69d8\u898b\u771f\u4f3c\u3067\u4f5c\u308c\u308b\u3088\u3046\u306b\u306f\u306a\u3063\u3066\u3044\u307e\u3059\u304c\uff0c<strong>\u305d\u308c\u3067\u306f\u7269\u8db3\u308a\u306a\u3044\u3068\u3044\u3046\u4e2d\u7d1a\u8005\u306e\u305f\u3081\u306b\uff0c\u7d30\u304b\u3044\u6587\u6cd5\u7684\u306a\u89e3\u8aac\u3082\u968f\u6240\u306b\u5165\u308c\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059<\/strong>\uff0e<\/p>\n<p>\u6ce8\u610f\u3068\u3057\u3066\uff0c\u672c\u8a18\u4e8b\u306fSwift\u306e\u8a00\u8a9e\u89e3\u8aac\u306f\u3042\u307e\u308a\u542b\u307e\u306a\u3044\u306e\u3067\uff0c\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u5225\u30bf\u30d6\u3067\u958b\u3044\u3066\u304a\u3044\u3066\uff0c\u5206\u304b\u3089\u306a\u3051\u308c\u3070\u9010\u4e00\u78ba\u8a8d\u3057\u3066\u307f\u308b\u3068\u826f\u3044\u3068\u601d\u3044\u307e\u3059\uff0e<\/p>\n<ol>\n<li><a href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1343\/\" target=\"_blank\" rel=\"noopener noreferrer\">Swift\u3092\u89e6\u3063\u305f\u3053\u3068\u304c\u306a\u3044\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u305f\u3081\u306eSwift\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb <i class=\"fas fa-external-link-alt\"><\/i><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>\u3061\u306a\u307f\u306b\u51fa\u6765\u4e0a\u304c\u308b\u30a2\u30d7\u30ea\u306f\uff0c\u4e0a\u56f3\u306b\u793a\u3059\u3088\u3046\u306a<strong>\u89b3\u5149\u5730\u30a2\u30d7\u30ea<\/strong>\u3067\u3059\uff0e<\/p>\n<p>\u5404\u89b3\u5149\u5730\u306e\u4f4d\u7f6e\u60c5\u5831\u3092\u78ba\u8a8d\u3057\u305f\u308a\uff0c\u305d\u306e\u89b3\u5149\u5730\u3092\u304a\u6c17\u306b\u5165\u308a\u306b\u8ffd\u52a0\u3057\u305f\u308a\u3067\u304d\u308b\u30a2\u30d7\u30ea\u3092\u76ee\u6307\u3057\u307e\u3059\uff0e<\/p>\n<p>\u7b2c1\u56de\u306f????<\/p>\n<div style=\"max-width: 450px; height: auto;\"><a href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1375\/\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1430\" src=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/thum1.png\" alt=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\" width=\"100%\" height=\"auto\" \/><\/a><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E7%AC%AC5%E5%9B%9E%EF%BC%9A%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%93%E3%83%A5%E3%83%BC%E3%81%A8%E9%81%B7%E7%A7%BB\"><\/span>\u7b2c5\u56de\uff1a\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30d3\u30e5\u30fc\u3068\u9077\u79fb<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4eca\u56de\u306f\uff0c\u524d\u56de\u3068\u4f3c\u305f\u3088\u3046\u306a\u5185\u5bb9\u306b\u306a\u308a\u307e\u3059\u304c\uff0c\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306b\u3064\u3044\u3066\u3067\u3059\uff0e<\/p>\n<p>\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u9077\u79fb\uff0c\u52d5\u304d\u3092\u3069\u3046\u5b9f\u88c5\u3057\u3066\u3044\u304f\u306e\u304b\uff0c\u3068\u3044\u3046\u3053\u3068\u3092\u4e2d\u5fc3\u306b\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\uff0e<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_1_%E3%83%8F%E3%82%A4%E3%82%AD%E3%83%B3%E3%82%B0%E3%83%A2%E3%83%87%E3%83%AB%E3%82%92%E4%BD%9C%E3%82%8B\"><\/span>Step 1. \u30cf\u30a4\u30ad\u30f3\u30b0\u30e2\u30c7\u30eb\u3092\u4f5c\u308b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u3053\u306e\u90e8\u5206\u306f\u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\uff0c\u4e88\u3081\u4f5c\u6210\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3044\u307e\u3059\u304c\uff0c\u672c\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u300c\u307b\u307c\u30bc\u30ed\u304b\u3089\u5b9f\u88c5\u300d\u3092\u76ee\u6a19\u3068\u3057\u3066\u3044\u307e\u3059\u306e\u3067\uff0c\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\uff0e<\/p>\n<p><strong>\u9762\u5012\u81ed\u3044\u3068\u3044\u3046\u65b9\u306f\uff0c\u6700\u5f8c\u306e\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30da\u3067\u3082\u69cb\u3044\u307e\u305b\u3093<\/strong>\uff0e<\/p>\n<p>\u3055\u3066\uff0c\u4eca\u304b\u3089\u4f55\u3092\u3059\u308b\u304b\u3068\u3044\u3046\u3068\uff0c\u4eca\u307e\u3067\u89b3\u5149\u5730\u30c7\u30fc\u30bf\u3092\u5143\u306b\u30d3\u30e5\u30fc\u3092\u4f5c\u6210\u3057\u3066\u304d\u307e\u3057\u305f\u304c\uff0c\u4eca\u56de\u306f<strong>\u672c\u30a2\u30d7\u30ea\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u9593\u306b\u884c\u3063\u305f\u30cf\u30a4\u30ad\u30f3\u30b0\u306e\u60c5\u5831\u3092\u53ef\u8996\u5316\u3057\u3088\u3046<\/strong>\u3068\u8003\u3048\u3066\u3044\u307e\u3059\uff0e<\/p>\n<p>\u4eca\u56de\u306f\uff0c\u5b9f\u969b\u306b\u30cf\u30a4\u30ad\u30f3\u30b0\u30c7\u30fc\u30bf\u304c\u300cResource\u300d\u306bJSON\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u5165\u3063\u3066\u3044\u308b\u3068\u601d\u3046\u306e\u3067\u305d\u308c\u3092\u4f7f\u7528\u3057\u307e\u3059\uff0e<\/p>\n<p>\u3082\u3057\uff0c\u7121\u3044\u65b9\u306f\u6539\u3081\u3066<a href=\"hen%20using SwiftUI, you can individually animate changes to views, or to a view\u2019s state, no matter where the effects are. SwiftUI handles all the complexity of these combined, overlapping, and interruptible animations for you. In this tutorial, you\u2019ll animate a view that contains a graph for tracking the hikes a user takes while using the Landmarks app. Using the animation(_:) modifier, you\u2019ll see just how easy it is to animate a view. Download the starter project and follow along with this tutorial, or open the finished project and explore the code on your own.\">Resource.zip<\/a>\u3092\u624b\u5143\u306b\u843d\u3068\u3057\u3066\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\uff0e<\/p>\n<p>\u307e\u305a\u306f\uff0cJSON\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\uff0e<\/p>\n<pre class=\"lang:swift decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">[\r\n    {\r\n        \"name\":\"Lonesome Ridge Trail\",  \/\/ \u30cf\u30a4\u30ad\u30f3\u30b0\u30b3\u30fc\u30b9\u540d\r\n        \"id\":1001,\r\n        \"distance\":4.5,  \/\/ \u8ddd\u96e2\r\n        \"difficulty\":3,  \/\/ \u96e3\u6613\u5ea6\r\n        \"observations\":[  \/\/ \u89b3\u6e2c\u30c7\u30fc\u30bf\r\n            {\r\n                \"elevation\":[  \/\/ \u6a19\u9ad8\r\n                    291.65263635636268,  \/\/ \u6700\u521d\r\n                    309.26016677925196   \/\/ \u6700\u5f8c\r\n                ],\r\n                \"pace\":[  \/\/ \u30da\u30fc\u30b9\r\n                    396.08716481908732,  \/\/ \u6700\u521d\r\n                    403.68937873525232   \/\/ \u6700\u5f8c\r\n                ],\r\n                \"heartRate\":[  \/\/ \u5fc3\u62cd\u6570\r\n                    117.16351898665887,  \/\/ \u6700\u521d\r\n                    121.95815455919609   \/\/ \u6700\u5f8c\r\n                ],\r\n                \"distanceFromStart\":0  \/\/ \u30b9\u30bf\u30fc\u30c8\u304b\u3089\u4f55km\u304b\r\n            },\r\n            {\r\n                \"elevation\":[\r\n                    299.24001936628116,\r\n                    317.44584350790012\r\n                ],\r\n                \"pace\":[\r\n                    380.19020240756623,\r\n                    395.3978319010256\r\n                ],\r\n                \"heartRate\":[\r\n                    117.6410892152911,\r\n                    124.82185220506081\r\n                ],\r\n                \"distanceFromStart\":0.375\r\n            },\r\n            ...\r\n\r\n]<\/pre>\n<p>\u305d\u308c\u305e\u308c\u4f55\u3092\u793a\u3057\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u306e\u306f\uff0c\u30b3\u30e1\u30f3\u30c8\u3092\u3064\u3051\u3066\u304a\u304d\u307e\u3057\u305f\uff0e<\/p>\n<p>\u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u8aac\u660e\u304c\u7121\u3044\u306e\u3067\uff0c\u3044\u307e\u3044\u3061\u30a4\u30e1\u30fc\u30b8\u304c\u3064\u304d\u3065\u3089\u3044\u3067\u3059\u3088\u306d\uff0e<\/p>\n<p>0.375km\u3054\u3068\u306b\uff0c\u6a19\u9ad8\uff0c\u30da\u30fc\u30b9\uff0c\u5fc3\u62cd\u6570\u3092\u8a18\u9332\u3057\u305f\u30c7\u30fc\u30bf\u3067\u3059\uff0e<\/p>\n<p>\u305d\u308c\u305e\u308c\u306e\u533a\u9593\u306b\u304a\u3051\u308b\uff0c<strong>\u521d\u671f\u5024\u3068\u5230\u9054\u5730\u70b9\u3067\u306e\u5024\u306e2\u3064\u306e\u30c7\u30fc\u30bf<\/strong>\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u307e\u3059\uff0e<\/p>\n<p><strong>\u3053\u306e\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\u305f\u3081\u306e\u30e2\u30c7\u30eb<\/strong>\u3092\u6700\u521d\u306b\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\uff0e<\/p>\n<p>\u65b0\u3057\u304fModels\u306b\u300cHike.swift\u300d\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\uff0e<\/p>\n<p>\u305d\u3057\u3066\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff0e<\/p>\n<pre class=\"lang:swift decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">import SwiftUI\r\n\r\nstruct Hike: Codable, Hashable, Identifiable {\r\n    var name: String\r\n    var id: Int\r\n    var distance: Double\r\n    var difficulty: Int\r\n    var observations: [Observation]\r\n\r\n    static var formatter = LengthFormatter()\r\n    \r\n    var distanceText: String {\r\n        return Hike.formatter\r\n            .string(fromValue: distance, unit: .kilometer)\r\n    }\r\n\r\n    struct Observation: Codable, Hashable {\r\n        var distanceFromStart: Double\r\n        \r\n        var elevation: Range&lt;Double&gt;\r\n        var pace: Range&lt;Double&gt;\r\n        var heartRate: Range&lt;Double&gt;\r\n    }\r\n}<\/pre>\n<p>\u30e2\u30c7\u30eb\u306e\u5b9f\u88c5\u306f\u4e00\u5ea6\u3084\u3063\u3066\u3044\u308b\u306e\u3067\uff0c\u7d30\u304b\u3044\u8aac\u660e\u306f\u7701\u304d\u307e\u3059\u304c<span class=\"lang:swift decode:true crayon-inline \">LengthFormatter()<\/span>\u00a0\u3060\u3051\u521d\u767b\u5834\u306a\u306e\u3067\u89e3\u8aac\u3057\u307e\u3059\uff0e<\/p>\n<p><span class=\"lang:swift decode:true crayon-inline\">LengthFormatter()<\/span> \u306f\u8ddd\u96e2\u306e\u5358\u4f4d\u3092\u5909\u63db\u3059\u308b\u305f\u3081\u306e\u30af\u30e9\u30b9\u3067\u3059\uff0e<\/p>\n<p>\u4f8b\u3048\u3070\u30e1\u30fc\u30c8\u30eb\u304b\u3089\u30ad\u30ed\u30e1\u30fc\u30c8\u30eb\u3078\u306e\u5909\u63db\u3084\uff0c\u30de\u30a4\u30eb\u3078\u306e\u5909\u63db\u306a\u3069\u3092\u7c21\u5358\u306b\u3057\u3066\u304f\u308c\u307e\u3059\uff0e<\/p>\n<p>\u4ed6\u306b\u3082\uff0c\u8cea\u91cf\u7cfb\u306e<span class=\"lang:swift decode:true crayon-inline \">MassFormatter()<\/span> \u306a\u3069\u69d8\u3005\u306aFormatter\u304c\u5b58\u5728\u3057\u307e\u3059\uff0e<\/p>\n<p>\u305d\u3046\u3057\u305f\u3089\uff0c\u3053\u308c\u3082\u300cData.swift\u300d\u3067\u8aad\u307f\u8fbc\u3080\u3088\u3046\u306b\u3057\u307e\u3059\uff0e(\u516c\u5f0f\u3067\u306f\u3044\u3064\u306e\u9593\u306b\u304b? ModelData.swift\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u306d)<\/p>\n<pre class=\"lang:swift mark:6 decode:true \" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">import UIKit\r\nimport SwiftUI\r\nimport CoreLocation\r\n\r\nlet landmarkData: [Landmark] = load(\"landmarkData.json\")\r\nlet hikeData: [Hike] = load(\"hikeData.json\")\r\n\r\n...<\/pre>\n<p>\u3053\u308c\u3067\u4e0b\u6e96\u5099\u306f\u5b8c\u4e86\u3067\u3059\uff0e<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_2_%E5%80%8B%E5%88%A5%E3%83%93%E3%83%A5%E3%83%BC%E3%81%B8%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B\"><\/span>Step 2. \u500b\u5225\u30d3\u30e5\u30fc\u3078\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3066\u307f\u308b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u5148\u307b\u3069\u4e0b\u6e96\u5099\u306f\u5b8c\u4e86\u3057\u305f\uff0c\u3068\u8a00\u3044\u307e\u3057\u305f\u304c\u672c\u984c\u306b\u5165\u308b\u524d\u306b\uff0c\u307e\u3060\u3084\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\uff0e<\/p>\n<p>\u307e\u305a\uff0c\u8aad\u307f\u8fbc\u3093\u3060<strong>\u30cf\u30a4\u30ad\u30f3\u30b0\u30c7\u30fc\u30bf\u3092\u53ef\u8996\u5316\u3057\u305f\u30d3\u30e5\u30fc<\/strong>\u3092\u5b9f\u88c5\u3057\u305f\u3044\u306e\u3067\u3059\u304c\uff0c\u3053\u308c\u306f\u516c\u5f0f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u3082\u89e3\u8aac\u306f\u306a\u304f\uff0c\u3053\u308c\u3092\u89e3\u8aac\u3057\u3066\u3044\u308b\u3068\u5197\u9577\u306b\u306a\u308b\u306e\u3067\uff0c\u30b3\u30fc\u30c9\u306e\u4e2d\u8eab\u3068\u30b3\u30e1\u30f3\u30c8\u3060\u3051\u3067\u6e08\u307e\u305b\u307e\u3059\uff0e<\/p>\n<p>\u4e00\u3064\u76ee\u306f\u300cGraphCapsule.swift\u300d\u3067\u3059\uff0e<\/p>\n<p>\u3053\u308c\u306f\uff0c<strong>\u533a\u9593\u3054\u3068\u306b\u8a18\u9332\u3057\u305f\u30c7\u30fc\u30bf\u3092\u9ad8\u3055\u3068\u3057\u305f\u6955\u5186\u578b\u306e\u30d3\u30e5\u30fc<\/strong>\u3092\u63cf\u753b\u3059\u308b\u69cb\u9020\u4f53\u3067\u3059\uff0e<\/p>\n<pre class=\"lang:swift decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">import SwiftUI\r\n\r\nstruct GraphCapsule: View {\r\n    var index: Int                  \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\r\n    var height: CGFloat             \/\/ \u30d3\u30e5\u30fc(\u5916\u67a0)\u306e\u9ad8\u3055\r\n    var range: Range&lt;Double&gt;        \/\/ \u6955\u5186\u306e\u5927\u304d\u3055 = \u89b3\u6e2c\u30c7\u30fc\u30bf\u7bc4\u56f2\r\n    var overallRange: Range&lt;Double&gt; \/\/ \u89b3\u6e2c\u30c7\u30fc\u30bf\u5168\u4f53\u306e\u7bc4\u56f2\r\n    \r\n    \/\/ \u6955\u5186\u306e\u5927\u304d\u3055\u5168\u4f53\u306e\u7bc4\u56f2\u304b\u3089\u7b97\u51fa\r\n    var heightRatio: CGFloat {\r\n        max(CGFloat(magnitude(of: range) \/ magnitude(of: overallRange)), 0.15)\r\n    }\r\n    \r\n    \/\/ \u6955\u5186\u306e\u4f4d\u7f6e\u3092\u7b97\u51fa\r\n    var offsetRatio: CGFloat {\r\n        CGFloat((range.lowerBound - overallRange.lowerBound) \/ magnitude(of: overallRange))\r\n    }\r\n    \r\n    var body: some View {\r\n        Capsule()\r\n            .fill(Color.white)\r\n            .frame(height: height * heightRatio)    \/\/ \u5fc5\u305a\u30d3\u30e5\u30fc\u306b\u53ce\u307e\u308b\u3088\u3046\u306b\u3059\u308b\r\n            .offset(x: 0, y: height * -offsetRatio)\r\n    }\r\n}\r\n\r\nstruct GraphCapsule_Previews: PreviewProvider {\r\n    static var previews: some View {\r\n        GraphCapsule(index: 0, height: 150, range: 10..&lt;50, overallRange: 0..&lt;100)\r\n    }\r\n}<\/pre>\n<p><span class=\"lang:swift decode:true crayon-inline\">magnitude(of: )<\/span> \u95a2\u6570\u306f\u3053\u306e\u5f8c\u4f5c\u6210\u3059\u308b\u300cHikeGraph.swift\u300d\u3067\u5b9a\u7fa9\u3057\u307e\u3059\uff0e<\/p>\n<p>\u3053\u3061\u3089\u306e\u30d5\u30a1\u30a4\u30eb\u306f\uff0c\u5148\u307b\u3069\u306e<strong>\u300cGraphCupsule\u300d\u3092\u547c\u3073\u51fa\u3057\u3066\u5b9f\u969b\u306b\u89b3\u6e2c\u30c7\u30fc\u30bf\u3092\u53ef\u8996\u5316\u3059\u308b\u30d3\u30e5\u30fc<\/strong>\u306b\u306a\u308a\u307e\u3059\uff0e<\/p>\n<p>\u305d\u306e\u4ed6\uff0c\u3044\u304f\u3064\u304b\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\uff0e<\/p>\n<p>\u4ee5\u4e0b\uff0c\u300cHikeGraph.swift\u300d\u3067\u3059\uff0e<\/p>\n<pre class=\"lang:swift decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">import SwiftUI\r\n\r\n\/\/ \u53d7\u3051\u53d6\u3063\u305f\u8907\u6570\u306e\u30c7\u30fc\u30bf\u304b\u3089\u5168\u4f53\u306e\u6700\u5c0f\u5024\u304b\u3089\u6700\u5927\u5024\u306e\u7bc4\u56f2\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8fd4\u3059\u95a2\u6570\r\nfunc rangeOfRanges&lt;C: Collection&gt;(_ ranges: C) -&gt; Range&lt;Double&gt; where C.Element == Range&lt;Double&gt; {\r\n        \r\n    guard !ranges.isEmpty else { return 0..&lt;0 }\r\n    let low = ranges.lazy.map { $0.lowerBound }.min()!\r\n    let high = ranges.lazy.map { $0.upperBound }.max()!\r\n    return low..&lt;high\r\n}\r\n\r\n\/\/ \u7bc4\u56f2\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5927\u304d\u3055\u3092\u8fd4\u3059\u95a2\u6570\r\nfunc magnitude(of range: Range&lt;Double&gt;) -&gt; Double {\r\n    return range.upperBound - range.lowerBound\r\n}\r\n\r\n\/\/ \u5207\u308a\u66ff\u3048\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u8a18\r\nextension Animation {\r\n    static func ripple(index: Int) -&gt; Animation {\r\n        Animation.spring(dampingFraction: 0.5)\r\n            .speed(2)\r\n            .delay(0.03 * Double(index))\r\n    }\r\n}\r\n\r\n\/\/ \u30d3\u30e5\u30fc\u8a2d\u5b9a\r\nstruct HikeGraph: View {\r\n    var hike: Hike\r\n    var path: KeyPath&lt;Hike.Observation, Range&lt;Double&gt;&gt;\r\n    \r\n    \/\/ \u30b8\u30e3\u30f3\u30eb\u306b\u3088\u3063\u3066\u8272\u3092\u5909\u3048\u308b\r\n    var color: Color {\r\n        switch path {\r\n        case \\.elevation:\r\n            return .gray\r\n        case \\.heartRate:\r\n            return Color(hue: 0, saturation: 0.5, brightness: 0.7)\r\n        case \\.pace:\r\n            return Color(hue: 0.7, saturation: 0.4, brightness: 0.7)\r\n        default:\r\n            return .black\r\n        }\r\n    }\r\n    \r\n    var body: some View {\r\n        \/\/ \u89b3\u6e2c\u30c7\u30fc\u30bf\u914d\u5217\u3092\u5168\u3066\u53d6\u5f97\r\n        let data = hike.observations\r\n        \r\n        \/\/ \u89b3\u6e2c\u30c7\u30fc\u30bf\u305d\u308c\u305e\u308c\u306e\u5168\u4f53\u7bc4\u56f2\u3092\u53d6\u5f97\r\n        let overallRange = rangeOfRanges(data.lazy.map { $0[keyPath: self.path] })\r\n        \r\n        \/\/ \u30c7\u30fc\u30bf\u6700\u5927\u5024\r\n        let maxMagnitude = data.map { magnitude(of: $0[keyPath: path]) }.max()!\r\n        \r\n        \/\/ \u30c7\u30fc\u30bf\u6700\u5927\u5024\u3092\u3082\u3068\u306b\u30d3\u30e5\u30fc\u306e\u9ad8\u3055\u6bd4\u7387\u3092\u6c7a\u3081\u308b\r\n        let heightRatio = (1 - CGFloat(maxMagnitude \/ magnitude(of: overallRange)))\r\n\r\n        \/\/ \u30d3\u30e5\u30fc\u3092\u69cb\u7bc9\r\n        return GeometryReader { proxy in\r\n            HStack(alignment: .bottom, spacing: proxy.size.width \/ 120) {\r\n                ForEach(data.indices) { index in\r\n                    GraphCapsule(\r\n                        index: index,\r\n                        height: proxy.size.height,\r\n                        range: data[index][keyPath: self.path],\r\n                        overallRange: overallRange)\r\n                    .colorMultiply(self.color)\r\n                    .transition(.slide)\r\n                    .animation(.ripple(index: index))\r\n                }\r\n                .offset(x: 0, y: proxy.size.height * heightRatio)\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nstruct HikeGraph_Previews: PreviewProvider {\r\n    static var previews: some View {\r\n        Group {\r\n            HikeGraph(hike: hikeData[0], path: \\.elevation)\r\n                .frame(height: 200)\r\n            HikeGraph(hike: hikeData[0], path: \\.heartRate)\r\n                .frame(height: 200)\r\n            HikeGraph(hike: hikeData[0], path: \\.pace)\r\n                .frame(height: 200)\r\n        }\r\n    }\r\n}<\/pre>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1590\" src=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-1.png\" alt=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\" width=\"1200\" height=\"894\" srcset=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-1.png 1200w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-1-300x224.png 300w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-1-768x572.png 768w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-1-1024x763.png 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>\u3053\u306e\u3068\u304d\u300cxxx may have crashed\u300d\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3089\uff0cJSON\u30d5\u30a1\u30a4\u30eb\u304c\u30d3\u30eb\u30c9\u30bf\u30fc\u30b2\u30c3\u30c8\u306b\u5165\u3063\u3066\u3044\u306a\u3044\u3053\u3068\u304c\u8003\u3048\u3089\u308c\u307e\u3059\uff0e<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1591\" src=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-2.png\" alt=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\" width=\"1200\" height=\"866\" srcset=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-2.png 1200w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-2-300x217.png 300w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-2-768x554.png 768w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2020\/08\/5-2-1024x739.png 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>...<\/p>\n<p>\u3053\u3053\u3067\u521d\u3081\u3066\u51fa\u3066\u304d\u305f<span class=\"lang:swift decode:true crayon-inline \">KeyPath&lt;&gt;<\/span>\u00a0\u306b\u3064\u3044\u3066\uff0e<\/p>\n<p><span class=\"lang:swift decode:true crayon-inline \">KeyPath<\/span> \u306f\u69cb\u9020\u4f53\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u5bfe\u3057\u3066<strong>\u52d5\u7684\u306a\u30a2\u30af\u30bb\u30b9\u3092\u53ef\u80fd\u3068\u3059\u308b<\/strong>\u4e00\u7a2e\u306e\u578b (\u30af\u30e9\u30b9) \u3067\u3059\uff0e<\/p>\n<p>\u8907\u96d1\u306a\u69cb\u9020\u4f53\u3067\u3042\u308b\u307b\u3069\u305d\u306e\u30e1\u30ea\u30c3\u30c8\u3092\u767a\u63ee\u3059\u308b\u308f\u3051\u3067\u3059\u304c\uff0c\u5b9f\u969b\u306b<span class=\"lang:swift decode:true crayon-inline\">struct HikeGraph<\/span>\u00a0\u5185\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u306f\uff0c<\/p>\n<pre class=\"lang:swift decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">struct HikeGraph: View {\r\n    var hike: Hike\r\n    var path: KeyPath&lt;Hike.Observation, Range&lt;Double&gt;&gt;\r\n\r\n    \/\/ ...\r\n}<\/pre>\n<p>\u3068\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u306d\uff0e<\/p>\n<p>\u3053\u308c\u306f\uff0c<span class=\"lang:swift decode:true crayon-inline \">struct Hike &gt; struct Observation<\/span> \u3068\u3044\u3046\u8907\u96d1\u306a\u69cb\u9020\u3092\u3057\u305f\u69cb\u9020\u4f53\u306b\u5bfe\u3057\u3066\u306eKeyPath\uff0c\u3064\u307e\u308a\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u30d1\u30b9\u3092\u4e00\u3064\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u6e08\u307e\u305b\u3066\u3044\u307e\u3059\uff0e<\/p>\n<p>\u4eca\u306f\u30a4\u30e1\u30fc\u30b8\u304c\u3064\u304d\u306b\u304f\u3044\u3067\u3059\u304c\uff0c\u3053\u3053\u306e\u90e8\u5206\uff0c\u3042\u3068\u3067\u307e\u305f\u51fa\u3066\u304f\u308b\u306e\u3067\u3061\u3087\u3063\u3068\u899a\u3048\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\uff0e<\/p>\n<p>...<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_3_HikeView%E3%82%92%E4%BD%9C%E3%82%8B\"><\/span>Step 3. HikeView\u3092\u4f5c\u308b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u6b21\u306b\uff0c<span class=\"lang:swift decode:true crayon-inline\">struct HikeGraph<\/span>\u00a0\u3092\u4f7f\u3063\u3066\u8a73\u7d30\u30c7\u30fc\u30bf\u306e\u30d3\u30e5\u30fc\u300cHikeDetail.swift\u300d\u3068\u305d\u308c\u3092\u4e00\u89a7\u3068\u3057\u3066\u64cd\u4f5c\u3059\u308b\u5927\u67a0\u306e\u30d3\u30e5\u30fc\u300cHikeView.swift\u300d\u3092\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\uff0e<\/p>\n<p>\u307e\u305a\u306f\u300cHikeDetail.swift\u300d\u304b\u3089\uff0e<\/p>\n<p>\u3053\u306e\u30d3\u30e5\u30fc\u3067\u306f\uff0cHikeData\u304b\u30893\u3064\u306e\u4e3b\u8981\u30c7\u30fc\u30bf\u300cElevation (\u6a19\u9ad8)\u300d\u300cHeartRate (\u5fc3\u62cd)\u300d\u300cPace (\u30da\u30fc\u30b9)\u300d\u3092\u5168\u3066\u4e00\u3064\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3067\uff0c<strong>\u30dc\u30bf\u30f3\u306b\u3088\u3063\u3066\u3053\u308c\u3089\u306e\u30b0\u30e9\u30d5\u3092\u5207\u308a\u66ff\u3048\uff0c\u8868\u793a\u3059\u308b\u5f79\u5272<\/strong>\u3092\u62c5\u3044\u307e\u3059\uff0e<\/p>\n<p>\u3068\u3082\u304b\u304f\uff0c\u30b3\u30e1\u30f3\u30c8\u4ed8\u304d\u3067\u30b3\u30fc\u30c9\u5168\u4f53\u3092\u898b\u305b\u307e\u3059\uff0e<\/p>\n<pre class=\"lang:swift decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">import SwiftUI\r\n\r\nstruct HikeDetail: View {\r\n    let hike: Hike\r\n    @State var dataToShow = \\Hike.Observation.elevation  \/\/ KeyPath&lt;&gt;: \u521d\u671f\u5024\u3082\u8a2d\u5b9a\r\n    \/\/ \u2191 \u578b\u306f\u660e\u8a18\u3057\u3066\u3044\u306a\u3044\u304c\uff0c\u672c\u5f53\u306f KeyPath&lt;Hike.Observation, Range&lt;Double&gt;&gt; \u3068\u3044\u3046\u578b\u306b\u306a\u308b\r\n\r\n    var buttons = [  \/\/ (\u30dc\u30bf\u30f3\u8868\u793a\u540d, \u305d\u306e\u5024\u3078\u306eKeyPath)\u3068\u3044\u3046\u30bf\u30d7\u30eb\u914d\u5217\r\n        (\"Elevation\", \\Hike.Observation.elevation),\r\n        (\"Heart Rate\", \\Hike.Observation.heartRate),\r\n        (\"Pace\", \\Hike.Observation.pace)\r\n    ]\r\n\r\n    var body: some View {\r\n        return VStack {\r\n            HikeGraph(hike: hike, path: dataToShow)  \/\/ Hike\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3068\uff0c\u8868\u793a\u3059\u308b\u3082\u306e\u306eKeyPath\u3092\u6e21\u3057\u3066\u3044\u308b\r\n                .frame(height: 200)\r\n\r\n            HStack(spacing: 25) {\r\n                ForEach(buttons, id: \\.0) { value in\r\n                    Button(action: {\r\n                        self.dataToShow = value.1  \/\/ \u30bf\u30d7\u30eb\u306e2\u3064\u76ee\u306e\u8981\u7d20(=KeyPath)\u3092\u4ee3\u5165\u3059\u308b\u3068\u3044\u3046\u30a2\u30af\u30b7\u30e7\u30f3\r\n                    }) {\r\n                        Text(value.0)  \/\/ \u30dc\u30bf\u30f3\u30c6\u30ad\u30b9\u30c8\u306f\u30bf\u30d7\u30eb\u306e1\u3064\u76ee(=String)\r\n                            .font(.system(size: 15))\r\n                            .foregroundColor(value.1 == self.dataToShow  \/\/ \u4e09\u9805\u6f14\u7b97\u5b50: \u3082\u3057\u30bf\u30d7\u30eb\u4e8c\u756a\u76ee\u8981\u7d20\u3068\u4eca\u8868\u793a\u3057\u3066\u3044\u308bKeyPath\u304c\u4e00\u81f4\u3057\u3066\u3044\u308b\u306a\u3089\u3070\r\n                                ? Color.gray\r\n                                : Color.accentColor)\r\n                            .animation(nil)  \/\/ \u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306f\u6307\u5b9a\u306a\u3057\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nstruct HikeDetail_Previews: PreviewProvider {\r\n    static var previews: some View {\r\n        HikeDetail(hike: hikeData[0])\r\n    }\r\n}<\/pre>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1743\" src=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/5-3.png\" alt=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\" width=\"1024\" height=\"534\" srcset=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/5-3.png 1024w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/5-3-300x156.png 300w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/5-3-768x401.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>\u3053\u3053\u3067\u3082\uff0c<strong>KeyPath<\/strong>\u304c\u51fa\u3066\u304d\u307e\u3057\u305f\uff0e<\/p>\n<p>\u3057\u304b\u3057\uff0c\u3053\u306e\u30b3\u30fc\u30c9\u3092\u307f\u308b\u3068\u306a\u3093\u3068\u306a\u304f\u305d\u306e\u4f7f\u3044\u65b9\u304c\u898b\u3048\u3066\u304f\u308b\u306f\u305a\u3067\u3059\uff0e<\/p>\n<p>KeyPath\u306f\uff0c<span class=\"lang:swift decode:true crayon-inline \">\\<\/span> \u3092\u5148\u982d\u306b\u3064\u3051\u308b\u3053\u3068\u3067\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\uff0c\u305d\u306e\u578b\u306f\u3053\u306e\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306b\u521d\u671f\u5024\u304c\u3042\u308c\u3070\u660e\u8a18\u3057\u306a\u304f\u3066\u3082\u63a8\u6e2c\u3057\u3066\u304f\u308c\u307e\u3059\u304c\uff0c\u5148\u306b\u89e6\u308c\u305f\u300cHikeGraph.swift\u300d\u3067\u306f\u521d\u671f\u5024\u304c\u306a\u304b\u3063\u305f\u305f\u3081\uff0c<span class=\"lang:swift decode:true crayon-inline \">KeyPath&lt;Hike.Observation, Range&lt;Double&gt;&gt;<\/span>\u00a0 \u3068\u578b\u3092\u660e\u8a18\u3057\u3066\u3044\u305f\u308f\u3051\u3067\u3059\u306d\uff0e<\/p>\n<p>C\/C++\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30dd\u30a4\u30f3\u30bf\u3068\u3082\u5c11\u3057\u4f3c\u3066\u3044\u307e\u3059\u306d\uff0e<\/p>\n<p>\u3055\u3066\uff0c\u6b21\u306b\u300cHikeView.swift\u300d\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff0e<\/p>\n<p>\u305d\u306e\u5185\u5bb9\u306f\uff0cLandmarkView\u3068\u4f3c\u3066\u3044\u3066\uff0cStack\u3092\u5229\u7528\u3057\u3066\u4eca\u3064\u304f\u3063\u305fHikeDetail\u30d3\u30e5\u30fc\u3092\u547c\u3073\u51fa\u3059UI\u3092\u4f5c\u6210\u3057\u307e\u3059\uff0e<\/p>\n<p>\u3053\u308c\u3082\u30b3\u30fc\u30c9\u5168\u5bb9\u3092\u63b2\u8f09\u3057\u3066\u3057\u307e\u3044\u307e\u3059\uff0e<\/p>\n<pre class=\"lang:swift decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">import SwiftUI\r\n\r\nstruct HikeView: View {\r\n    var hike: Hike\r\n    @State private var showDetail = false\r\n\r\n    var body: some View {\r\n        VStack {\r\n            HStack {\r\n                HikeGraph(hike: hike, path: \\.elevation)  \/\/ \u3053\u3053\u3067\u3082KeyPath: \u4eca\u56de\u306fHike.Observation\u3067\u3042\u308b\u3053\u3068\u306f\u5b9a\u7fa9\u304b\u3089\u81ea\u660e\u306a\u306e\u3067\uff0c\u7701\u7565\u3057\u3066 \\. \u3068\u8868\u8a18\u3057\u3066\u3044\u308b\r\n                    .frame(width: 50, height: 30)\r\n\r\n                VStack(alignment: .leading) {\r\n                    Text(hike.name)\r\n                        .font(.headline)\r\n                    Text(hike.distanceText)\r\n                }\r\n                \r\n                Spacer()\r\n\r\n                Button(action: {\r\n                    self.showDetail.toggle()\r\n                }) {\r\n                    Image(systemName: \"chevron.right.circle\")\r\n                        .imageScale(.large)\r\n                        .rotationEffect(.degrees(showDetail ? 90 : 0))\r\n                        .padding()\r\n                        .animation(.easeInOut)  \/\/ \u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u9077\u79fb\u306b\u3064\u3044\u3066\u306e\u5b9a\u7fa9\r\n                }\r\n            }\r\n\r\n            if showDetail {\r\n                HikeDetail(hike: self.hike)\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nstruct HikeView_Previews: PreviewProvider {\r\n    static var previews: some View {\r\n        VStack {\r\n            HikeView(hike: hikeData[0])\r\n                .padding()\r\n            Spacer()\r\n        }\r\n    }\r\n}<\/pre>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1744\" src=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/5-4.png\" alt=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\" width=\"1024\" height=\"539\" srcset=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/5-4.png 1024w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/5-4-300x158.png 300w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/5-4-768x404.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306a\u3069\u306e\u52d5\u4f5c\u306f\u307f\u306a\u3055\u3093\u306e\u76ee\u3067\u78ba\u304b\u3081\u3066\u307f\u3066\u304f\u3060\u3055\u3044\uff0e<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_4_%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E8%AA%BF%E6%95%B4%E3%81%99%E3%82%8B\"><\/span>Step 4. \u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8abf\u6574\u3059\u308b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u3053\u3053\u307e\u3067\u3067\u3082\u5341\u5206UI\u3068\u3057\u3066\u306f\u6a5f\u80fd\u3057\u3066\u3044\u307e\u3059\uff0e<\/p>\n<p>\u304c\uff0c\u3082\u3046\u5c11\u3057\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306b\u62d8\u3063\u3066\u307f\u307e\u3057\u3087\u3046\uff0e<\/p>\n<pre class=\"lang:swift mark:16 decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">struct HikeView: View {\r\n    var hike: Hike\r\n    @State private var showDetail = false\r\n\r\n    var body: some View {\r\n        VStack {\r\n            HStack {\r\n                \/\/ ... \r\n\r\n                Button(action: {\r\n                    self.showDetail.toggle()\r\n                }) {\r\n                    Image(systemName: \"chevron.right.circle\")\r\n                        .imageScale(.large)\r\n                        .rotationEffect(.degrees(showDetail ? 90 : 0))\r\n                        .scaleEffect(showDetail ? 1.5 : 1)  \/\/ \u4e09\u9805\u6f14\u7b97\u5b50: \u8a73\u7d30\u8868\u793a\u3057\u3066\u3044\u308b\u306a\u30891.5\u500d\u306b\r\n                        .padding()\r\n                        .animation(.easeInOut)\r\n                }\r\n            }\r\n            \/\/ ...\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u4f8b\u3048\u3070\uff0c\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u8a73\u7d30\u8868\u793a\u3059\u308b\u3068\u304d\u306b\u77e2\u5370\u3092\u5927\u304d\u304f\u3057\u3066\u307f\u305f\u308a\uff0e<\/p>\n<pre class=\"lang:swift mark:18 decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">struct HikeView: View {\r\n    var hike: Hike\r\n    @State private var showDetail = false\r\n\r\n    var body: some View {\r\n        VStack {\r\n            HStack {\r\n                \/\/ ... \r\n\r\n                Button(action: {\r\n                    self.showDetail.toggle()\r\n                }) {\r\n                    Image(systemName: \"chevron.right.circle\")\r\n                        .imageScale(.large)\r\n                        .rotationEffect(.degrees(showDetail ? 90 : 0))\r\n                        .scaleEffect(showDetail ? 1.5 : 1)\r\n                        .padding()\r\n                        .animation(.spring())  \/\/ \u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5909\u3048\u3066\u307f\u308b (\u9055\u3044\u306f\u3088\u304f\u308f\u304b\u3089\u306a\u3044)\r\n                }\r\n            }\r\n            \/\/ ...\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u6319\u52d5\u3092\u5909\u3048\u3066\u307f\u305f\u308a\uff0e<\/p>\n<p>\u4ed6\u306b\u3082\uff0c<span class=\"lang:swift decode:true crayon-inline \">.default<\/span> <span class=\"lang:swift decode:true crayon-inline\">.easeIn<\/span> <span class=\"lang:swift decode:true crayon-inline\">.easeOut<\/span> \u306a\u3069\u8272\u3005\u306a\u6307\u5b9a\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\uff0e<\/p>\n<pre class=\"lang:swift mark:11-13 decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">struct HikeView: View {\r\n    var hike: Hike\r\n    @State private var showDetail = false\r\n\r\n    var body: some View {\r\n        VStack {\r\n            HStack {\r\n                \/\/ ... \r\n\r\n                Button(action: {\r\n                    withAnimation(.easeInOut(duration: 2)) { \/\/ 2\u79d2\u304b\u3051\u3066\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\r\n                        self.showDetail.toggle()\r\n                    }\r\n                }) {\r\n                    Image(systemName: \"chevron.right.circle\")\r\n                        .imageScale(.large)\r\n                        .rotationEffect(.degrees(showDetail ? 90 : 0))\r\n                        .scaleEffect(showDetail ? 1.5 : 1)\r\n                        .padding()\r\n                        .animation(.spring())\r\n            }\r\n            \/\/ ...\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u3053\u3093\u306a\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff0e<\/p>\n<p>\u30d5\u30ef\u30fc\u3063\u3068\u8868\u793a\u3055\u308c\u308b\u304b\u3068\u601d\u3044\u307e\u3059\uff0e<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_5_%E5%87%9D%E3%81%A3%E3%81%9F%E3%82%A2%E3%83%8B%E3%83%A1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E8%A8%AD%E5%AE%9A\"><\/span>Step 5. \u51dd\u3063\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u3082\u3046\u5c11\u3057\uff0c\u8907\u96d1\u3067\u51dd\u3063\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3082\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff0e<\/p>\n<p>\u672c\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\uff0c\u5148\u307b\u3069\u3082\u7c21\u5358\u306b\u3044\u3058\u3063\u305fHikeDetail\u306e\u8868\u793a\u306b\u3064\u3044\u3066\u3082\u3046\u5c11\u3057\u8a73\u7d30\u306b\u5b9a\u7fa9\u3057\u3066\u3044\u304d\u307e\u3059\uff0e<\/p>\n<p>\u307e\u305a\u306f\uff0c\u5148\u307b\u3069\u306e\u30b3\u30fc\u30c9\u3092\u4e00\u90e8\u5143\u306b\u623b\u3057\u307e\u3059\uff0e<\/p>\n<pre class=\"lang:swift mark:11 decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">struct HikeView: View {\r\n    var hike: Hike\r\n    @State private var showDetail = false\r\n\r\n    var body: some View {\r\n        VStack {\r\n            HStack {\r\n                \/\/ ... \r\n\r\n                Button(action: {\r\n                    withAnimation { \r\n                        self.showDetail.toggle()\r\n                    }\r\n                }) {\r\n                    Image(systemName: \"chevron.right.circle\")\r\n                        .imageScale(.large)\r\n                        .rotationEffect(.degrees(showDetail ? 90 : 0))\r\n                        .scaleEffect(showDetail ? 1.5 : 1)\r\n                        .padding()\r\n                        .animation(.spring())\r\n            }\r\n            \/\/ ...\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u305d\u3046\u3057\u305f\u3089\uff0c\u4eee\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b9\u30e9\u30a4\u30c9\u3057\u3066\u8868\u793a\u3055\u305b\u308b\u30b3\u30fc\u30c9\u3092\u8ffd\u8a18\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<pre class=\"lang:swift mark:13 decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">struct HikeView: View {\r\n    var hike: Hike\r\n    @State private var showDetail = false\r\n\r\n    var body: some View {\r\n        VStack {\r\n            HStack {\r\n                \/\/ ...\r\n            }\r\n\r\n            if showDetail {\r\n                HikeDetail(hike: self.hike)\r\n                    .transition(.slide)\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u3053\u308c\u3060\u3051\u3067\u3082\uff0c\u5341\u5206\u30ab\u30c3\u30b3\u826f\u3044\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306a\u306e\u3067\u3059\u304c\uff0c\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u3082\u3046\u5c11\u3057\u7d30\u304b\u304f\uff0c\u81ea\u5206\u597d\u307f\u306b\u5b9a\u7fa9\u3057\u3066\u307f\u307e\u3059\uff0e<\/p>\n<p>\u305d\u3093\u306a\u3068\u304d\u306f\uff0c\u81ea\u5206\u3067\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u5b9a\u7fa9\u3057\u3066<span class=\"lang:swift decode:true crayon-inline \">.slide<\/span>\u00a0\u306e\u3088\u3046\u306b\u6271\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\uff0e<\/p>\n<p>\u305d\u306e\u5834\u5408\u306f\uff0c<span class=\"lang:swift decode:true crayon-inline\">extension<\/span> \u3092\u4f7f\u3063\u3066<strong>\u69cb\u9020\u4f53 (\u307e\u305f\u306f\u30af\u30e9\u30b9\u3084\u5217\u6319\u578b) \u3092\u62e1\u5f35<\/strong>\u3057\u3066\u3057\u307e\u3044\u307e\u3059\uff0e<\/p>\n<p><span class=\"lang:swift decode:true crayon-inline \">.transition()<\/span>\u00a0\u306e\u5f15\u6570\u578b\u306f<span class=\"lang:swift decode:true crayon-inline \">AnyTransition<\/span> \u306a\u306e\u3067...<\/p>\n<pre class=\"lang:swift mark:1-7,21 decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">extension AnyTransition {\r\n    \/\/ \u65b0\u305f\u306bAnyTransitoin\u306b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0 (\u62e1\u5f35: extension) \u3059\u308b\r\n    \r\n    static var moveAndFade: AnyTransition {  \/\/ moveAndFade\u3068\u3044\u3046\u540d\u524d\u3092\u65b0\u305f\u306b\u5b9a\u7fa9\r\n        AnyTransition.slide\r\n    }\r\n}\r\n\r\nstruct HikeView: View {\r\n    var hike: Hike\r\n    @State private var showDetail = false\r\n\r\n    var body: some View {\r\n        VStack {\r\n            HStack {\r\n                \/\/ ...\r\n            }\r\n\r\n            if showDetail {\r\n                HikeDetail(hike: self.hike)\r\n                    .transition(.moveAndFade)  \/\/ \u3053\u3053\u3067\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u308b\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u3068\uff0c\u3053\u306e\u3088\u3046\u306b\u62e1\u5f35\u3057\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff0e<\/p>\n<p>\u3053\u3053\u307e\u3067\u306f\u5148\u307b\u3069\u3068\u6319\u52d5\u306f\u306a\u3093\u3089\u5909\u308f\u308a\u307e\u305b\u3093\uff0e<\/p>\n<p>\u3053\u3053\u304b\u3089\u306f\uff0c\u4eca\u4f5c\u6210\u3057\u305f<span class=\"lang:swift decode:true crayon-inline \">moveAndFade<\/span> \u3092\u3055\u3089\u306b\u7d30\u304b\u304f\u4ed5\u69d8\u3092\u6c7a\u3081\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff0e<\/p>\n<pre class=\"lang:swift mark:3 decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">extension AnyTransition {\r\n    static var moveAndFade: AnyTransition {\r\n        AnyTransition.move(edge: .trailing)  \/\/ \u540c\u3058\u7aef\u304b\u3089\u30d5\u30ec\u30fc\u30e0\u30a4\u30f3\u30a2\u30a6\u30c8\u3059\u308b\u3088\u3046\u306b\u306a\u308b\r\n    }\r\n}\r\n\r\nstruct HikeView: View {\r\n    var hike: Hike\r\n    @State private var showDetail = false\r\n\r\n    var body: some View {\r\n        VStack {\r\n            HStack {\r\n                \/\/ ...\r\n            }\r\n\r\n            if showDetail {\r\n                HikeDetail(hike: self.hike)\r\n                    .transition(.moveAndFade)  \/\/ \u3053\u3053\u3067\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u308b\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u307e\u305a\u306f\uff0c\u52d5\u304d\u3092\u30b7\u30f3\u30e1\u30c8\u30ea\u30c3\u30af\u306b\u3057\u3066\u307f\u307e\u3057\u305f\uff0e<\/p>\n<p><span class=\"lang:swift decode:true crayon-inline\">.move(edge: .trailing)<\/span> \u306f\uff0cTrailing (\u53f3\u7aef) \u304b\u3089\u30d5\u30ec\u30fc\u30e0\u30a4\u30f3\u30a2\u30a6\u30c8\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\uff0e<\/p>\n<p>\u4ed6\u306b\u3082\uff0c<span class=\"lang:swift decode:true crayon-inline\">.top<\/span> <span class=\"lang:swift decode:true crayon-inline\">.bottom<\/span>\u00a0<span class=\"lang:swift decode:true crayon-inline\">.leading<\/span>\u00a0\u304c\u4f7f\u7528\u3067\u304d\u307e\u3059\uff0e<\/p>\n<p>\u3053\u3053\u3067\uff0c\u30d5\u30ec\u30fc\u30e0\u30a4\u30f3\u3068\u30a2\u30a6\u30c8\uff0c\u7570\u306a\u308b\u52d5\u304d\u3092\u5b9f\u88c5\u3057\u305f\u3044\u5834\u5408\u306f<span class=\"lang:swift decode:true crayon-inline \">AnyTransition.asymmetric(insertion: , removal: )<\/span>\u00a0\u3092\u5229\u7528\u3057\u307e\u3059\uff0e<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4f7f\u3044\u65b9\u3067\u3059\uff0e<\/p>\n<pre class=\"lang:swift mark:3-9 decode:true \" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">extension AnyTransition {\r\n    static var moveAndFade: AnyTransition {\r\n        let insertion = AnyTransition.move(edge: .trailing)  \/\/ \u30d5\u30ec\u30fc\u30e0\u30a4\u30f3\r\n            .combined(with: .opacity)  \/\/ \u900f\u904e\u3092\u4f34\u3063\u3066\r\n        \r\n        let removal = AnyTransition.scale  \/\/ \u30d5\u30ec\u30fc\u30e0\u30a2\u30a6\u30c8\r\n            .combined(with: .opacity)\r\n        \r\n        return .asymmetric(insertion: insertion, removal: removal)  \/\/ \u30a2\u30b7\u30f3\u30e1\u30c8\u30ea (\u975e\u5bfe\u79f0) \u306a\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u8a2d\u5b9a\r\n    }\r\n}<\/pre>\n<p><span class=\"lang:swift decode:true crayon-inline\">return<\/span> \u3082\u8ffd\u8a18\u3055\u308c\u307e\u3057\u305f\u304c\uff0c<a href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1343\/#%E6%A7%8B%E9%80%A0%E4%BD%93_(struct)\" target=\"_blank\" rel=\"noopener noreferrer\">Computed propaty<\/a>\u3092\u899a\u3048\u3066\u3044\u308c\u3070\u4e0d\u601d\u8b70\u304c\u308b\u3053\u3068\u306f\u306a\u3044\u3067\u3057\u3087\u3046\uff0e<\/p>\n<p>\u3053\u308c\u3067\u975e\u5bfe\u79f0\u306a\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u304c\u5b9a\u7fa9\u3067\u304d\u307e\u3057\u305f\uff01<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_X_%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%82%92%E6%95%B4%E7%90%86%E3%81%99%E3%82%8B\"><\/span>Step X. \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u6574\u7406\u3059\u308b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u3053\u3053\u307e\u3067\uff0c\u672c\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u8ffd\u3063\u3066\u304d\u305f\u65b9\u306f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u4e71\u96d1\u306b\u306a\u3063\u3066\u304d\u3066\u3044\u307e\u305b\u3093\u304b\uff1f<\/p>\n<p>\u3053\u3053\u3067\u6574\u7406\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\uff0e<\/p>\n<p>\u672c\u6765\u3067\u3042\u308c\u3070\uff0c\u3053\u3046\u3044\u3063\u305f\u30a2\u30d7\u30ea\u3084\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u8a2d\u8a08\u3059\u308b\u6bb5\u968e\u304c\u660e\u78ba\u306b\u3042\u308a\uff0c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u3042\u308b\u7a0b\u5ea6\u6574\u7406\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u304c\uff0c\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u898b\u5207\u308a\u767a\u8eca\u306e\u3088\u3046\u306b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u59cb\u3081\u3066\u3057\u307e\u3063\u305f\u305f\u3081\uff0c\u30b3\u30fc\u30c9\u304c\u4e71\u96d1\u306b\u306a\u3063\u3066\u3044\u307e\u3059\uff0c<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066<\/p>\n<pre class=\"lang:swift decode:true\" title=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\">.\r\n\u251c\u2500\u2500 Landmarks\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 Badges\/\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Badge.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 BadgeBackground.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 BadgeSymbol.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 HexagonParameters.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 RotatedBadgeSymbol.swift\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 Helpers\/\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 CircleImage.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 MapView.swift\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 Hikes\/\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 GraphCapsule.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 HikeDetail.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 HikeGraph.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 HikeView.swift\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 Landmarks\/\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 LandmarkDetail.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 LandmarkList.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 LandmarkRow.swift\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 Models\/\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Data.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Hike.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 Landmark.swift\r\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 UserData.swift\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 Preview Content\/\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 Resources\/\r\n\u2514\u2500\u2500 Landmarks.xcodeproj<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067\uff0cBadge\u95a2\u9023\u306fBadges\/\u306b\uff0cHike\u95a2\u9023\u306fHikes\/\u306b\uff0c\u306e\u3088\u3046\u306b\u6574\u7406\uff08\u30b0\u30eb\u30fc\u30d7\u5316\uff09\u3057\u307e\u3059\uff0e\uff08\u4e00\u90e8\u30d5\u30a1\u30a4\u30eb\u306f\u7701\u7565\u3057\u3066\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\uff09<\/p>\n<p>\u65b0\u3057\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\uff08\u30b0\u30eb\u30fc\u30d7\uff09\u306e\u4f5c\u6210\u306f\uff0c\u4f5c\u6210\u3057\u305f\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u9020\uff08\u3053\u3053\u3067\u306f\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308bLandmarks\uff09\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b\u30c0\u30d6\u30eb\u30bf\u30c3\u30d7\uff0c\u305d\u306e\u4e2d\u306e\u300cNew Group\u300d\u304b\u3089\u3067\u304d\u307e\u3059\uff0e<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E7%AC%AC5%E5%9B%9E%EF%BC%9A%E3%81%8A%E3%82%8F%E3%82%8A%E3%81%AB\"><\/span>\u7b2c5\u56de\uff1a\u304a\u308f\u308a\u306b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4eca\u56de\u306f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9\u306e\u4ed5\u65b9\u306b\u3064\u3044\u3066\u5b66\u3073\u307e\u3057\u305f\uff0e<\/p>\n<p>\u9b45\u529b\u7684\u306a\u30a2\u30d7\u30ea\u306f\uff0c\u30af\u30fc\u30eb\u306a\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u304c\u7528\u3044\u3089\u308c\u3066\u3044\u308b\u3053\u3068\u3082\u5c11\u306a\u304f\u3042\u308a\u307e\u305b\u3093\uff0e<\/p>\n<p>\u305f\u3060\uff0c\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u53d6\u308a\u5165\u308c\u3059\u304e\u308b\u3068\u30a6\u30b6\u304f\u306a\u3063\u305f\u308a\u3059\u308b\u306e\u3067\uff0c\u4f7f\u7528\u91cf\u3092\u3046\u307e\u304f\u8abf\u6574\u3057\u3066\u4f7f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff0e<\/p>\n<p>\u3055\u3066\uff0c\u6b21\u56de\u304b\u3089\u306f\u4eca\u307e\u3067\u4f5c\u6210\u3057\u3066\u304d\u305f\u30d3\u30e5\u30fc\u3092\u7d71\u5408\u3057\uff0c\u4e00\u3064\u306e\u30a2\u30d7\u30ea\u306b\u307e\u3068\u3081\u4e0a\u3052\u3066\u3044\u304d\u307e\u3059\uff01<\/p>\n<p><a href=\"https:\/\/hirlab.net\/nblog\/category\/programming\/art_1750\/\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1774\" src=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/thum6.png\" alt=\"\u65e5\u672c\u8a9e\u7248SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\" width=\"1200\" height=\"727\" srcset=\"https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/thum6.png 1200w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/thum6-300x182.png 300w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/thum6-768x465.png 768w, https:\/\/hirlab.net\/nblog\/wp-content\/uploads\/2021\/03\/thum6-1024x620.png 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306f\uff0c\u57fa\u672c\u7684\u306b\u672c\u5bb6SwiftUI\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306b\u5023\u3063\u3066\u9032\u3081\u3066\u3044\u304d\u307e\u3059\uff0e\u305f\u3060\u516c\u5f0f\u3068\u9055\u3046\u70b9\u306f\u300c\u65e5\u672c\u8a9e\u3067\u3042\u308b\u3053\u3068\u300d\u3068\u300c\u89e3\u8aac\u3092\u7d30\u304b\u304f\u5165\u308c\u3066\u3042\u308b\u3053\u3068\u300d\u3067\u3059\uff0e\u306a\u306e\u3067\uff0c\u521d\u5fc3\u8005\u306f\u3082\u3061\u308d\u3093\uff0c\u4e2d\u7d1a\u8005\u30d7\u30ed\u30b0\u30e9\u30de\u306e\u65b9\u306b\u3082\u6e80\u8db3\u3057\u3066\u3082\u3089\u3048\u308b\u3088\u3046\u306a\u3082\u306e\u3092\u76ee\u6307\u3057\u3066\u3044\u307e\u3059\uff0e\u3055\u3066\u7b2c5\u56de\u76ee\u306f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30d3\u30e5\u30fc\u3068\u305d\u306e\u9077\u79fb\u306e\u5b9f\u88c5\u3067\u3059\uff01<\/p>\n","protected":false},"author":1,"featured_media":1583,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[83,81,82],"_links":{"self":[{"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/posts\/1582"}],"collection":[{"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/comments?post=1582"}],"version-history":[{"count":13,"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/posts\/1582\/revisions"}],"predecessor-version":[{"id":1811,"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/posts\/1582\/revisions\/1811"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/media\/1583"}],"wp:attachment":[{"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/media?parent=1582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/categories?post=1582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hirlab.net\/nblog\/wp-json\/wp\/v2\/tags?post=1582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}