{"id":912,"date":"2020-08-20T22:02:01","date_gmt":"2020-08-20T14:02:01","guid":{"rendered":"http:\/\/123.57.164.21\/?p=912"},"modified":"2020-08-21T10:31:18","modified_gmt":"2020-08-21T02:31:18","slug":"%e3%80%90swiftui-contentshape-%e6%89%a9%e5%a4%a7ontapgesture-%e9%a2%86%e5%9f%9f","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=912","title":{"rendered":"SwiftUI contentShape \u6269\u5927onTapGesture \u9886\u57df"},"content":{"rendered":"\n<p>SwiftUI\u3067\u3042\u308bView\u306b<code>onTapGesture<\/code>\u3092\u8a2d\u5b9a\u3057\u305f\u969b \u4e2d\u306b\u3042\u308b\u500b\u3005\u306eView\u3092\u30bf\u30c3\u30d7\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u3059\u304c \u305d\u306e\u4ed6\u306e\u9818\u57df\u306f\u30bf\u30c3\u30d7\u3057\u3066\u3082\u53cd\u5fdc\u3057\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u4f8b\u3048\u3070\u4e0b\u8a18\u3088\u3046\u306a<code>VStack<\/code>\u306b\u5bfe\u3057\u3066<code>onTapGesture<\/code>\u3092\u8a2d\u5b9a\u3057\u307e\u3059\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=\"\">import SwiftUI\n\nstruct ContentView: View {\n\n    @State private var checked = false\n\n    var body: some View {\n\n        VStack(spacing: 20) {\n            Image(systemName: checked ? \"checkmark.seal.fill\" : \"checkmark.seal\")\n                .foregroundColor(checked ? .green : .gray)\n            Text(\"\u753b\u50cf\u3068\u30c6\u30ad\u30b9\u30c8\u306e\u307fTap\u3067\u304d\u308b\")\n        }\n        .frame(width: 300, height: 200)\n        .padding()\n        .background(RoundedRectangle(cornerRadius: 20).stroke(Color.green, lineWidth: 1))\n        \/\/ \ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\n        .onTapGesture {\n            self.checked.toggle()\n        }\n        .font(.title)\n    }\n}\n\nstruct ContentView_Previews: PreviewProvider {\n    static var previews: some View {\n        ContentView()\n    }\n}\n\n<\/pre>\n\n\n\n<p>\u4e0a\u8a18\u306e\u5834\u5408\u3067\u3059\u3068<br>VStack\u306e\u4e2d\u306e\u753b\u50cf\u3068\u30c6\u30ad\u30b9\u30c8\u306b\u3057\u304b\u30bf\u30c3\u30d7\u3067\u304d\u307e\u305b\u3093\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\/08\/image-109-856x1024.png\" alt=\"\" class=\"wp-image-915\" width=\"448\" height=\"535\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-109-856x1024.png 856w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-109-251x300.png 251w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-109-768x919.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-109-830x993.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-109-230x275.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-109-350x419.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-109-480x574.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-109.png 1204w\" sizes=\"(max-width: 448px) 100vw, 448px\" \/><\/figure><\/div>\n\n\n\n<p>\u305d\u3093\u306a\u6642\u306b\u6d3b\u7528\u3067\u304d\u308b\u306e\u304c<code>contentShape<\/code>\u3067\u3059\u3002<br><a href=\"https:\/\/developer.apple.com\/documentation\/swiftui\/vstack\/3278318-contentshape\" rel=\"noreferrer noopener\" target=\"_blank\">https:\/\/developer.apple.com\/documentation\/swiftui\/vstack\/3278318-contentshape<\/a><\/p>\n\n\n\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u81ea\u8eab\u306ehit\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u3066\u304f\u308c\u308bView\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u67a0\u5185\u3092\u30bf\u30c3\u30d7\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\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 ContentView: View {\n\n    @State private var checked = false\n\n    var body: some View {\n\n        VStack(spacing: 20) {\n            Image(systemName: checked ? \"checkmark.seal.fill\" : \"checkmark.seal\")\n                .foregroundColor(checked ? .green : .gray)\n            Text(\"\u67a0\u306e\u4e2d\u306f\u5168\u90e8Tap\u3067\u304d\u308b\")\n        }\n        .frame(width: 300, height: 200)\n        .padding()\n        .background(RoundedRectangle(cornerRadius: 20).stroke(Color.green, lineWidth: 1))\n        \/\/ \ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\ud83d\udc47\ud83c\udffb\n        .contentShape(RoundedRectangle(cornerRadius: 20)) \n        .onTapGesture {\n            self.checked.toggle()\n        }\n        .font(.title)\n    }\n}\n\nstruct ContentView_Previews: PreviewProvider {\n    static var previews: some View {\n        ContentView()\n    }\n}<\/pre>\n\n\n\n<p>\u3059\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30bf\u30c3\u30d7\u30a8\u30ea\u30a2\u3092\u62e1\u5927\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\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\/08\/image-110-1024x812.png\" alt=\"\" class=\"wp-image-916\" width=\"523\" height=\"414\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-110-1024x812.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-110-300x238.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-110-768x609.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-110-830x658.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-110-230x182.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-110-350x278.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-110-480x381.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2020\/08\/image-110.png 1054w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/figure><\/div>\n\n\n\n<p>\u753b\u50cf\u3092\u30bf\u30c3\u30d7\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u3051\u308c\u3069<br>\u753b\u50cf\u3060\u3051\u3060\u3068\u30bf\u30c3\u30d7\u3067\u304d\u308b\u9818\u57df\u304c\u72ed\u3044\u5834\u5408\u306a\u3069\u306b<br>\u30b3\u30fc\u30c9\u3092\uff11\u884c\u52a0\u3048\u3066\u9818\u57df\u3092\u5e83\u3052\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u306f<br>\u5927\u5909\u4fbf\u5229\u3067\u3059\u306d\ud83d\ude04<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SwiftUI\u3067\u3042\u308bView\u306bonTapGesture\u3092\u8a2d\u5b9a\u3057\u305f\u969b \u4e2d\u306b\u3042\u308b\u500b\u3005\u306eView\u3092\u30bf\u30c3\u30d7\u3059\u308b\u3053\u3068\u306f\u3067 [&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\/912"}],"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=912"}],"version-history":[{"count":5,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/912\/revisions"}],"predecessor-version":[{"id":919,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/912\/revisions\/919"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}