{"id":32763,"date":"2024-11-01T09:11:22","date_gmt":"2024-11-01T09:11:22","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32763"},"modified":"2024-11-01T11:23:50","modified_gmt":"2024-11-01T11:23:50","slug":"swiftui-style-iphone-app-development-adding-swipe-functionality-to-gallery-app","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32763\/","title":{"rendered":"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App"},"content":{"rendered":"<p><body><\/p>\n<p>Nowadays, mobile applications place a significant emphasis on visual experience and user interface (UI). In particular, gallery apps must present photos and videos in an engaging way to users. This tutorial will explain how to develop an iPhone app using Swift and SwiftUI, as well as how to add swipe functionality to a gallery app.<\/p>\n<h2>1. What is SwiftUI?<\/h2>\n<p>SwiftUI is a new UI framework launched by Apple at WWDC 2019, enabling UI to be created using a declarative programming approach. SwiftUI reduces verbose code and provides immediate visual feedback, allowing the same code to be utilized across various Apple devices such as iPhone, iPad, and Mac.<\/p>\n<h2>2. Basic Structure of a Gallery App<\/h2>\n<p>A gallery app is designed for users to display and manage photos and videos. The basic structure of a gallery app is as follows:<\/p>\n<ul>\n<li><strong>Item List:<\/strong> Displays available photos and videos in a list format.<\/li>\n<li><strong>Detail View:<\/strong> Shows detailed information about the selected item.<\/li>\n<li><strong>Swipe Functionality:<\/strong> Allows easy navigation to the previous\/next item.<\/li>\n<\/ul>\n<h2>3. Setting Up the SwiftUI Environment<\/h2>\n<p>To use SwiftUI, you need Xcode 11 or later. Follow these steps to start a new project:<\/p>\n<ol>\n<li>Launch Xcode and select &#8220;Create a new Xcode project.&#8221;<\/li>\n<li>Select &#8220;App&#8221; from the project template and click &#8220;Next.&#8221;<\/li>\n<li>Name your project, select SwiftUI, and click &#8220;Next.&#8221;<\/li>\n<li>Choose the location to save your project and click &#8220;Create.&#8221;<\/li>\n<\/ol>\n<h2>4. Building a Basic Gallery App<\/h2>\n<h3>4.1 Data Modeling<\/h3>\n<p>Since the gallery app displays photos and videos, you need to define a data model. Here\u2019s a simple data model you can create:<\/p>\n<pre><code>import Foundation\nstruct GalleryItem: Identifiable {\n    var id = UUID()\n    var imageName: String\n    var title: String\n    var description: String\n}<\/code><\/pre>\n<h3>4.2 Preparing Data<\/h3>\n<p>Prepare the data to be used in the gallery app. Create gallery items containing image files and related information:<\/p>\n<pre><code>let galleryItems: [GalleryItem] = [\n    GalleryItem(imageName: \"photo1\", title: \"Photo 1\", description: \"Description of the first photo.\"),\n    GalleryItem(imageName: \"photo2\", title: \"Photo 2\", description: \"Description of the second photo.\"),\n    GalleryItem(imageName: \"photo3\", title: \"Photo 3\", description: \"Description of the third photo.\")\n]<\/code><\/pre>\n<h3>4.3 Implementing the List View<\/h3>\n<p>Implement the list view to allow users to view gallery items. Below is an example of a basic list view:<\/p>\n<pre><code>import SwiftUI\n\nstruct GalleryListView: View {\n    var body: some View {\n        NavigationView {\n            List(galleryItems) { item in\n                NavigationLink(destination: GalleryDetailView(item: item)) {\n                    HStack {\n                        Image(item.imageName)\n                            .resizable()\n                            .scaledToFit()\n                            .frame(width: 100, height: 100)\n                        VStack(alignment: .leading) {\n                            Text(item.title)\n                                .font(.headline)\n                            Text(item.description)\n                                .font(.subheadline)\n                        }\n                    }\n                }\n            }\n            .navigationTitle(\"Gallery\")\n        }\n    }\n}<\/code><\/pre>\n<h3>4.4 Implementing the Detail View<\/h3>\n<p>Implement the detail view that will be displayed when a user selects a specific gallery item:<\/p>\n<pre><code>struct GalleryDetailView: View {\n    var item: GalleryItem\n    \n    var body: some View {\n        VStack {\n            Image(item.imageName)\n                .resizable()\n                .aspectRatio(contentMode: .fit)\n            Text(item.title)\n                .font(.largeTitle)\n                .padding()\n            Text(item.description)\n                .font(.body)\n                .padding()\n        }\n    }\n}<\/code><\/pre>\n<h2>5. Adding Swipe Functionality<\/h2>\n<p>To add swipe functionality, you can use SwiftUI&#8217;s <code>TabView<\/code> and <code>PageTabViewStyle<\/code>. This allows users to swipe left or right to view the gallery items.<\/p>\n<h3>5.1 Implementing the View for Swipe Functionality<\/h3>\n<pre><code>struct GallerySwipeView: View {\n    var items: [GalleryItem]\n\n    var body: some View {\n        TabView {\n            ForEach(items) { item in\n                GalleryDetailView(item: item)\n            }\n        }\n        .tabViewStyle(PageTabViewStyle())\n    }\n}<\/code><\/pre>\n<h3>5.2 Implementing Swipe Functionality<\/h3>\n<p>Allow users to navigate to the previous and next items using the swipe functionality in the detail view of the selected gallery item. To do this, integrate <code>GallerySwipeView<\/code> into <code>GalleryDetailView<\/code>:<\/p>\n<pre><code>struct GalleryDetailView: View {\n    var item: GalleryItem\n    var body: some View {\n        GallerySwipeView(items: galleryItems) \/\/ Swipe view including the selected gallery item\n    }\n}<\/code><\/pre>\n<p>With this setup, users can easily navigate through the gallery items by swiping.<\/p>\n<h2>6. Check the Results<\/h2>\n<p>Now run the gallery app to verify if the swipe functionality works correctly. Ensure that all gallery items are listed and that users can easily navigate to the previous and next items by swiping. It&#8217;s also important to review if the UI elements are properly arranged and user-friendly.<\/p>\n<h2>Conclusion<\/h2>\n<p>We have built a simple gallery app using SwiftUI and added swipe functionality. Thanks to SwiftUI&#8217;s declarative syntax, we can deliver an excellent user experience with concise code. As you continue to add other features and enhance the design, challenge yourself to provide a richer gallery experience.<\/p>\n<p>I hope this tutorial has provided useful information, and I encourage you to enhance your skills through more app development experiences!<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nowadays, mobile applications place a significant emphasis on visual experience and user interface (UI). In particular, gallery apps must present photos and videos in an engaging way to users. This tutorial will explain how to develop an iPhone app using Swift and SwiftUI, as well as how to add swipe functionality to a gallery app. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32763\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[125],"tags":[],"class_list":["post-32763","post","type-post","status-publish","format-standard","hentry","category-swift-iphone-app-development-swiftui"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/32763\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Nowadays, mobile applications place a significant emphasis on visual experience and user interface (UI). In particular, gallery apps must present photos and videos in an engaging way to users. This tutorial will explain how to develop an iPhone app using Swift and SwiftUI, as well as how to add swipe functionality to a gallery app. &hellip; \ub354 \ubcf4\uae30 &quot;SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32763\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:11:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:23:50+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/32763\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32763\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App\",\"datePublished\":\"2024-11-01T09:11:22+00:00\",\"dateModified\":\"2024-11-01T11:23:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32763\/\"},\"wordCount\":527,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Swift iPhone app development (SwiftUI)\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32763\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32763\/\",\"name\":\"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:11:22+00:00\",\"dateModified\":\"2024-11-01T11:23:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32763\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32763\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32763\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/32763\/","og_locale":"ko_KR","og_type":"article","og_title":"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Nowadays, mobile applications place a significant emphasis on visual experience and user interface (UI). In particular, gallery apps must present photos and videos in an engaging way to users. This tutorial will explain how to develop an iPhone app using Swift and SwiftUI, as well as how to add swipe functionality to a gallery app. &hellip; \ub354 \ubcf4\uae30 \"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App\"","og_url":"https:\/\/atmokpo.com\/w\/32763\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:11:22+00:00","article_modified_time":"2024-11-01T11:23:50+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/32763\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32763\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App","datePublished":"2024-11-01T09:11:22+00:00","dateModified":"2024-11-01T11:23:50+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32763\/"},"wordCount":527,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Swift iPhone app development (SwiftUI)"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32763\/","url":"https:\/\/atmokpo.com\/w\/32763\/","name":"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:11:22+00:00","dateModified":"2024-11-01T11:23:50+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32763\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32763\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32763\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"SwiftUI Style, iPhone App Development, Adding Swipe Functionality to Gallery App"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=32763"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32763\/revisions"}],"predecessor-version":[{"id":32764,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32763\/revisions\/32764"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}