<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hui Fan on Medium]]></title>
        <description><![CDATA[Stories by Hui Fan on Medium]]></description>
        <link>https://medium.com/@vincent941017?source=rss-8f6efc1743ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-Otct1AHwH1WsfEC</url>
            <title>Stories by Hui Fan on Medium</title>
            <link>https://medium.com/@vincent941017?source=rss-8f6efc1743ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 17:25:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vincent941017/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[#11 從 0 到 1 做一款記帳 App:  Expense Tracking (1)|unwind segue, 永久儲存, Table View]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/11-%E5%BE%9E-0-%E5%88%B0-1-%E5%81%9A%E4%B8%80%E6%AC%BE%E8%A8%98%E5%B8%B3-app-expense-tracking-1-unwind-segue-%E6%B0%B8%E4%B9%85%E5%84%B2%E5%AD%98-table-view-509f982c9548?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/509f982c9548</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 04:34:02 GMT</pubDate>
            <atom:updated>2025-09-14T08:55:05.635Z</atom:updated>
            <content:encoded><![CDATA[<h3>#11 從 0 到 1 做一款記帳 App: Expense Tracking (1) | unwind segue, 永久儲存, Table View</h3><p>最近在課堂上學到 <strong>unwind segue</strong> 與 <strong>資料儲存（data persistence）</strong>，我想把這些知識用在一個貼近日常的作品上：<strong>Expense Tracker 記帳 App</strong>。</p><p>這系列文章會從 <strong>畫面與功能設計</strong> 出發，一步一步把 App 做起來；本篇是 <strong>Part 1</strong>，先定 UI 架構與資料規格，之後再把互動與儲存串起來。跟著我，一起把想法變成可用的 App！</p><h3>畫面設計</h3><h4>主畫面</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*7l_S9ui_D2ooycQFz42SmA.png" /></figure><h4>Add Record 畫面</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*-ApqMzhthM0238nTh2e99g.png" /></figure><h3>規劃重點（Key Concepts）</h3><ul><li><strong>Unwind Segue（回到上一頁並帶資料）: </strong>用於「新增紀錄頁 → 首頁」的資料回傳，讓新增後能即時更新清單與總額。</li><li><strong>資料儲存（Persistence）: </strong>以 FileManager 與 <strong>documentsDirectory</strong> 做「永久儲存」，預計使用 <strong>JSON</strong> 格式（可讀性高、好除錯）。</li><li><strong>Table View（清單呈現） &amp; Cell 建置: </strong>以 UITableView 顯示收支紀錄；規劃自訂 cell、左滑刪除/編輯。</li><li><strong>資料格式設計: </strong>設計資料儲存的Json格式。</li></ul><h3>畫面設計 draft</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_eZ6kqqDg29FRZQG0TtdSQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=509f982c9548" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/11-%E5%BE%9E-0-%E5%88%B0-1-%E5%81%9A%E4%B8%80%E6%AC%BE%E8%A8%98%E5%B8%B3-app-expense-tracking-1-unwind-segue-%E6%B0%B8%E4%B9%85%E5%84%B2%E5%AD%98-table-view-509f982c9548">#11 從 0 到 1 做一款記帳 App:  Expense Tracking (1)|unwind segue, 永久儲存, Table View</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#10 iOS SDK 內建 controller：影片播放、網頁瀏覽、Alert警告視窗與選單]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/10-ios-sdk-%E5%85%A7%E5%BB%BA-controller-%E5%BD%B1%E7%89%87%E6%92%AD%E6%94%BE-%E7%B6%B2%E9%A0%81%E7%80%8F%E8%A6%BD-alert%E8%AD%A6%E5%91%8A%E8%A6%96%E7%AA%97%E8%88%87%E9%81%B8%E5%96%AE-43e6fbcf3ad7?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/43e6fbcf3ad7</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Mon, 01 Sep 2025 08:02:22 GMT</pubDate>
            <atom:updated>2025-09-01T15:55:43.723Z</atom:updated>
            <content:encoded><![CDATA[<p>在日常的 <strong>iOS App 開發</strong> 中，經常需要呼叫系統提供的 <strong>SDK 功能</strong>，例如 <strong>播放影音</strong>、<strong>開啟內建瀏覽器</strong>、<strong>彈出警告訊息或輸入框</strong>，以及 <strong>提供選單的介面</strong>。這篇文章會透過一個 <strong>簡單的範例專案</strong>，示範如何在 <strong>單一畫面中整合這些常見功能</strong>。</p><h3>成果展示</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*tc1Xu4KA8x0POZoaoMdrlg.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vikeAm547UwFOIbsGu7gZw.png" /></figure><p>畫面包含五個按鈕與一個輸入框，功能對應如下：</p><ul><li><strong>Play Video</strong>：播放線上影片</li><li><strong>Show Website</strong>：開啟 Safari 內嵌網頁</li><li><strong>Confirm</strong>：輸入電話號碼後彈出確認訊息</li><li><strong>Log in</strong>：顯示登入視窗，可輸入帳號密碼</li><li><strong>Choose Level</strong>：由下而上的選單（Easy / Medium / Hard）</li></ul><h3>功能重點</h3><ol><li><strong>AVPlayerViewController</strong> → 播放線上或本地影片（設定點選自動開始播放）</li><li><strong>SFSafariViewController</strong> → 在 App 內嵌開啟網頁</li><li><strong>UIAlertController (alert, text fields)</strong> → 錯誤提示、確認訊息、登入輸入框</li><li><strong>UIAlertController (actionSheet)</strong> → 選單操作</li></ol><p><strong>這些元件幾乎是 iOS 開發的必備工具，能讓 App 更直覺、更具功能性。</strong></p><h3>GitHub URL</h3><p><a href="https://github.com/PolarBear1017/iOS_SDK_controller">GitHub - PolarBear1017/iOS_SDK_controller</a></p><h3>教學連結</h3><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/62-%E9%80%8F%E9%81%8E-present-animated-completion-%E9%A1%AF%E7%A4%BA-ios-sdk-%E5%85%A7%E5%BB%BA%E7%9A%84-10-%E7%A8%AE-controller-5b178f792359">#62 顯示 iOS SDK 內建的 controller</a></p><h3><strong>參考連結</strong></h3><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E9%A1%AF%E7%A4%BA%E8%AD%A6%E5%91%8A%E8%A8%8A%E6%81%AF%E5%92%8C%E9%81%B8%E5%96%AE%E7%9A%84-uialertcontroller-a7548b606eea">顯示警告訊息和選單的 UIAlertController</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43e6fbcf3ad7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/10-ios-sdk-%E5%85%A7%E5%BB%BA-controller-%E5%BD%B1%E7%89%87%E6%92%AD%E6%94%BE-%E7%B6%B2%E9%A0%81%E7%80%8F%E8%A6%BD-alert%E8%AD%A6%E5%91%8A%E8%A6%96%E7%AA%97%E8%88%87%E9%81%B8%E5%96%AE-43e6fbcf3ad7">#10 iOS SDK 內建 controller：影片播放、網頁瀏覽、Alert警告視窗與選單</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#09 MBTI 心理測驗 App： 實作JSON 解碼與 IBSegueAction 跨頁傳遞]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/09-mbti-%E5%BF%83%E7%90%86%E6%B8%AC%E9%A9%97-app-%E5%AF%A6%E4%BD%9Cjson-%E8%A7%A3%E7%A2%BC%E8%88%87-ibsegueaction-%E8%B7%A8%E9%A0%81%E5%82%B3%E9%81%9E-f830c0fa489c?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/f830c0fa489c</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Sat, 23 Aug 2025 10:46:54 GMT</pubDate>
            <atom:updated>2025-08-23T13:45:51.491Z</atom:updated>
            <content:encoded><![CDATA[<p>還記得第一次做心理測驗時，那種「好奇自己會是哪一型人格」的心情嗎？</p><p>這次我做了一個 <strong>MBTI 心理測驗 App</strong>！讓使用者透過幾個問題，就能快速得出屬於自己的 MBTI 結果。</p><p>但在這個小專案裡，我不只是單純做出問答流程，還順便練習了許多 iOS 開發的核心觀念。來分享一下這次踩過的坑與學到的重點吧 🚀</p><h3>成果展示</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*F1DHoUKKpUX6S3f2PdlpVw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNqMrDoDYVfJeHEAHZnX9w.png" /></figure><h3>Storyboard</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ice3PnKMonA2wChYugIvYQ.png" /></figure><h3>🎯 功能亮點</h3><ol><li><strong>JSON 網路抓資料</strong></li></ol><p>測驗題目沒有直接寫死在程式裡，而是放在 JSON 檔案中，再透過 URLSession 從遠端抓取。這樣以後要更新題目，只需要改 JSON 就好，App 本身不用重新編譯。</p><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E6%90%AD%E9%85%8D-ai-%E5%BB%BA%E7%AB%8B%E8%87%AA%E5%B7%B1%E6%84%9F%E8%88%88%E8%B6%A3%E7%9A%84-json-api-f8c3f51cf81d">搭配 AI 建立自己感興趣的 JSON API</a></p><h4>好用的 JSON Editor Online</h4><p><a href="https://jsoneditoronline.org/#">https://jsoneditoronline.org/#</a></p><p><strong>2. 背景執行與 Main Thread UI 更新</strong></p><p>用 URLSession 抓資料時會在背景執行（background thread）。資料處理完後，要記得透過 DispatchQueue.main.async 回到 main thread 更新 UI，不然 UILabel 與 UIButton 會沒辦法顯示正確的內容。</p><p><strong>3. JSONDecoder 解碼</strong></p><p>利用 JSONDecoder 把 JSON 格式的資料解碼成 Swift 的結構，搭配 do { try … } catch {} 做錯誤處理，避免當資料格式不符時直接閃退，錯誤時還能顯示是哪部分有問題需要修改。</p><p><strong>4. self 的使用</strong></p><p>在 escaping closure（例如 URLSession、GCD 這種 “<strong>非同步執行的 closure” </strong>）中，如果要存取 class 的屬性或方法，必須加上 self，這是 Swift 在記憶體管理上的一個安全機制。</p><p>如圖當在 URLSession.shared.dataTask(with: url) { (data, response, error) in } 這個 “<strong>非同步執行的 closure<em>” </em></strong>中，當要存取 所處 class 的屬性或方法時，就必須加上 self. （粉色字體的 self.）</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o1YZ4SvMSDiuR8rzrgsGIg.png" /></figure><h4><strong>💡 小提醒：URLSession 與 .resume()</strong></h4><p>使用 URLSession.shared.dataTask 建立請求時，有一個很容易忘記的點：</p><p>👉 <strong>它預設是「暫停」狀態！</strong>必須呼叫 <strong>.resume()</strong>，才會實際去執行 dataTask 的任務。</p><p><strong>5. 連接多個 UIButton 到同一個 Outlet Collection &amp; IBAction 的處理技巧</strong></p><ul><li>使用 <strong>Outlet Collection</strong> 把所有選項按鈕綁在同一個陣列裡。</li><li>搭配 enumerated()，可以在更新畫面時，依序設定每個按鈕的文字內容</li><li>讓所有選項按鈕共用同一個 @<strong>IBAction</strong> func tapOptionButton(_ sender: UIButton)。</li><li>用 optionButton.firstIndex(of: sender) 判斷使用者點擊了哪個按鈕，進而記錄答案。</li></ul><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E5%B0%87%E5%A4%9A%E5%80%8B%E5%85%83%E4%BB%B6%E9%80%A3%E5%88%B0%E5%90%8C%E4%B8%80%E5%80%8B-ibaction-function-4de52f54b1a8">將多個元件連到同一個 IBAction function</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E5%8D%80%E5%88%86%E9%80%A3%E5%88%B0%E5%90%8C%E4%B8%80%E5%80%8B-ibaction-function-%E7%9A%84%E5%A4%9A%E5%80%8B%E5%85%83%E4%BB%B6-e2d51eb6cd1e">區分連到同一個 IBAction function 的多個元件</a></li></ul><p><strong>6. Segue 與跨頁資料傳遞</strong></p><ul><li>測驗結束後，用 <strong>performSegue</strong> 觸發頁面切換。</li><li>使用 <strong>IBSegueAction</strong>，把計算出來的 <strong>MBTI 結果傳給結果頁</strong> TestResultViewController。</li></ul><p><strong>7. WebView 顯示額外內容</strong></p><p>我還加了一個 WKWebView 來顯示 MBTI 的相關介紹網站。雖然一開始遇到 <em>「Could not instantiate class named WKWebView」</em> 的錯誤，但後來照著教學一步一步設定framework，就能順利顯示了。（教學如下）</p><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/could-not-instantiate-class-named-wkwebview-%E5%95%8F%E9%A1%8C-8402cb1a2c86">Could not instantiate class named WKWebView 問題</a></li><li><a href="https://www.16personalities.com/tw/%E6%80%A7%E6%A0%BC%E9%A1%9E%E5%9E%8B">人格類型 | 16Personalities</a></li></ul><h3>JSON URL</h3><p><a href="https://raw.githubusercontent.com/PolarBear1017/MBTI_personality_test/refs/heads/main/MbtiQuestion.json">https://raw.githubusercontent.com/PolarBear1017/MBTI_personality_test/refs/heads/main/MbtiQuestion.json</a></p><h3>GitHub URL</h3><p><a href="https://github.com/PolarBear1017/MBTI_personality_test/tree/main">GitHub - PolarBear1017/MBTI_personality_test</a></p><h3>教學連結</h3><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/16-%E5%BF%83%E7%90%86%E6%B8%AC%E9%A9%97%E6%88%96%E5%95%8F%E5%8D%B7-app-d8910d1345e">#16 心理測驗或問卷 App</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E6%90%AD%E9%85%8D-ai-%E5%BB%BA%E7%AB%8B%E8%87%AA%E5%B7%B1%E6%84%9F%E8%88%88%E8%B6%A3%E7%9A%84-json-api-f8c3f51cf81d">搭配 AI 建立自己感興趣的 JSON API</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/19-%E4%B8%B2%E6%8E%A5%E7%AC%AC%E4%B8%89%E6%96%B9-api-%E8%A7%A3%E6%9E%90-json-%E8%B3%87%E6%96%99%E9%A1%AF%E7%A4%BA-f1556e84daec">#19 串接第三方 API，解析 JSON 資料，轉換成自訂型別顯示</a></li></ul><h3>參考連結</h3><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E6%90%AD%E9%85%8D-ai-%E5%BB%BA%E7%AB%8B%E8%87%AA%E5%B7%B1%E6%84%9F%E8%88%88%E8%B6%A3%E7%9A%84-json-api-f8c3f51cf81d">搭配 AI 建立自己感興趣的 JSON API</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E5%B0%87%E5%A4%9A%E5%80%8B%E5%85%83%E4%BB%B6%E9%80%A3%E5%88%B0%E5%90%8C%E4%B8%80%E5%80%8B-ibaction-function-4de52f54b1a8">將多個元件連到同一個 IBAction function</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E5%8D%80%E5%88%86%E9%80%A3%E5%88%B0%E5%90%8C%E4%B8%80%E5%80%8B-ibaction-function-%E7%9A%84%E5%A4%9A%E5%80%8B%E5%85%83%E4%BB%B6-e2d51eb6cd1e">區分連到同一個 IBAction function 的多個元件</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/could-not-instantiate-class-named-wkwebview-%E5%95%8F%E9%A1%8C-8402cb1a2c86">Could not instantiate class named WKWebView 問題</a></li><li><a href="https://www.16personalities.com/tw/%E6%80%A7%E6%A0%BC%E9%A1%9E%E5%9E%8B">人格類型 | 16Personalities</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f830c0fa489c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/09-mbti-%E5%BF%83%E7%90%86%E6%B8%AC%E9%A9%97-app-%E5%AF%A6%E4%BD%9Cjson-%E8%A7%A3%E7%A2%BC%E8%88%87-ibsegueaction-%E8%B7%A8%E9%A0%81%E5%82%B3%E9%81%9E-f830c0fa489c">#09 MBTI 心理測驗 App： 實作JSON 解碼與 IBSegueAction 跨頁傳遞</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#08 用 Page Control、Segmented Control、Button 與 Gesture 打造環遊世界小旅行 ]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/08-%E7%94%A8-page-control-segmented-control-button-%E8%88%87-gesture-%E6%89%93%E9%80%A0%E7%92%B0%E9%81%8A%E4%B8%96%E7%95%8C%E5%B0%8F%E6%97%85%E8%A1%8C-b6d950fe54f5?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6d950fe54f5</guid>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 07:39:10 GMT</pubDate>
            <atom:updated>2025-08-20T01:24:46.709Z</atom:updated>
            <content:encoded><![CDATA[<p>在這次的專案裡，我設計了一個 <strong>Country Introduction App</strong>，讓使用者可以透過不同的操作方式來切換國家，彷彿展開一場小小的環遊世界之旅。</p><h3>成果展示</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*ubfby_tUX4kXKp5T_lm7Ew.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cXWm3ysBs7PcVGLf1Yj8pA.png" /></figure><h3>App 的主要功能</h3><ol><li><strong>Page Control 輪播展示</strong></li></ol><p>使用 UIPageControl 搭配 UIPageControlTimerProgress，可以自動每 3 秒輪播到下一個國家。這樣不需要手動操作，畫面就能自動切換，讓整個介面更有「旅遊簡報」的感覺。</p><p><strong>2. Segmented Control 快速選擇</strong></p><p>利用 UISegmentedControl，使用者可以直接點選想要看的國家，馬上跳轉到對應的介紹畫面。這樣在操作上更加直覺，也能快速比對不同國家的圖片與名稱。</p><p><strong>3. 左右按鈕切換</strong></p><p>加入了「上一頁」與「下一頁」按鈕 (clickLeftButton 與 clickRightButton)，讓使用者能像翻書一樣逐頁切換，操作方式簡單直觀。</p><p><strong>4. 手勢控制</strong></p><p>我也加入了滑動手勢 (UISwipeGestureRecognizer)，只要在圖片上往左或往右滑，就能切換國家。這樣的操作更貼近日常手機使用習慣，提升了互動性。</p><p><strong>5. 同步更新顯示</strong></p><p>每次切換國家時，App 會同時更新 <strong>國家名稱、圖片、Segmented Control、Page Control 與頁數標籤</strong>，我使用了 function 名為updateCountryIntroduction()，切換時即時同步，讓整個畫面保持一致。</p><p>透過這次的專案，我更熟悉這些 <strong>UIKit 的元件互動</strong>：</p><ul><li>UIPageControl 的自動輪播</li><li>UISegmentedControl 與 IBAction 的連動</li><li>Button 與 Gesture 的事件處理</li></ul><h3>GitHub URL</h3><p><a href="https://github.com/PolarBear1017/countryIntroduction">GitHub - PolarBear1017/countryIntroduction</a></p><h3>教學連結</h3><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/%E7%9C%9F%E6%84%9B%E7%9A%84%E6%A8%A1%E6%A8%A3-image-view-%E5%92%8C-segmented-control-%E7%B7%B4%E7%BF%92-675d64d5c94c">#38 利用 page control，segmented control，button &amp; gesture 更換內容</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E9%96%8B%E7%99%BC-ios-app-%E7%9A%84-gesture-%E6%89%8B%E5%8B%A2%E5%8A%9F%E8%83%BD-uikit-%E7%89%88%E6%9C%AC-f6cb95075705">開發 iOS App 的 Gesture (手勢)功能 — UIKit 版本</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6d950fe54f5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/08-%E7%94%A8-page-control-segmented-control-button-%E8%88%87-gesture-%E6%89%93%E9%80%A0%E7%92%B0%E9%81%8A%E4%B8%96%E7%95%8C%E5%B0%8F%E6%97%85%E8%A1%8C-b6d950fe54f5">#08 用 Page Control、Segmented Control、Button 與 Gesture 打造環遊世界小旅行 🌍</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#07 Random Food Picker 今天吃什麼？ | 用 UIKit + IBAction 幫你決定]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/07-random-food-picker-%E4%BB%8A%E5%A4%A9%E5%90%83%E4%BB%80%E9%BA%BC-%E7%94%A8-uikit-ibaction-%E5%B9%AB%E4%BD%A0%E6%B1%BA%E5%AE%9A-1308754aaf12?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1308754aaf12</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Thu, 14 Aug 2025 06:00:38 GMT</pubDate>
            <atom:updated>2025-08-14T09:43:29.621Z</atom:updated>
            <content:encoded><![CDATA[<p>每到吃飯時間，腦袋第一個問題常常在思考「今天要吃什麼？」</p><p>有時候選擇太多，反而更難下決定 ，今天我們就來用 <strong>UIKit</strong> 搭配 <strong>IBAction</strong>，做一個「<strong>隨機美食選擇器（Random Food Picker）</strong>」幫你解決選擇障礙！</p><h3>成品影片預覽</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*HXiO0SmKw8niIBFh0oBI_g.gif" /></figure><p>螢幕上有一句提示、一個可愛的問號方塊圖、以及一顆 <strong>Decide</strong> 按鈕。每點一次 <strong>Decide</strong> 按鈕，Label 就會顯示一種食物，並同步切換對應圖片。</p><h3>成品展示</h3><p>一進去顯示的封面:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w7x6cAJPNa-tDFpRDyQsFA.png" /></figure><p>抽到牛排 Steak :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HI-XUB7nYd_2PA2Op1b1PA.png" /></figure><p>抽到 Pizza :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ySuLJNbUB733Ro9eXA9Zw.png" /></figure><h3>你會學到什麼</h3><ul><li>如何用 <strong>Storyboard</strong> 佈局 Label、ImageView、Button</li><li>什麼是 <strong>IBOutlet</strong> / <strong>IBAction</strong>，以及它們如何連線到程式碼</li><li>使用 Array + randomElement() / Int.random(in:) 來產生隨機結果</li><li>把 <strong>Asset 的圖片名稱</strong> 與資料陣列對應起來，達到「文字、圖片一起換」</li></ul><h3>專案結構（簡述）</h3><ul><li>Main.storyboard：放一個 UILabel（顯示食物名稱）、一個 UIImageView（顯示食物圖）、一個 UIButton（觸發抽選）</li><li>Assets：加入與食物同名的圖片，如 steak, hamburger, ramen, sushi, pizza…</li><li>RandomFoodPickerViewController.swift：View Controller 核心邏輯</li></ul><h3>重點講解（Step by Step）</h3><h4>1. 資料來源：foodNameArray</h4><p>一個 String 陣列，內容同時扮演 <strong>顯示文字</strong> 與 <strong>圖片名稱</strong> 的 key。</p><p><em>小技巧：Asset 圖片檔名請跟陣列中的字串 </em><strong><em>完全一致</em></strong><em>（大小寫也要一致）。</em></p><h4>2. 介面連線：IBOutlet &amp; IBAction</h4><ul><li>@IBOutlet weak var foodNameLabel: Storyboard 上的 Label</li><li>@IBOutlet weak var foodPictureImageView: Storyboard 上的 ImageView</li><li>@IBAction func decide(_:): 連到「Decide」按鈕的 Touch Up Inside 事件</li></ul><h4>3. 隨機抽選：Int.random(in:)</h4><p>按鈕被點擊時：</p><ol><li>產生 foodIndex（0 ..&lt;陣列長度）</li><li>用 foodIndex 取出字串，更新 foodNameLabel</li><li>用同一個字串載入對應圖片：UIImage(named:)</li></ol><h3>GitHub URL</h3><p><a href="https://github.com/PolarBear1017/randomFoodPicker">GitHub - PolarBear1017/randomFoodPicker</a></p><h3>教學連結</h3><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/225-%E7%B5%90%E5%90%88%E5%9C%96%E7%89%87-%E6%96%87%E5%AD%97-button-%E7%9A%84-swiftui-state-%E7%B7%B4%E7%BF%92%E9%A1%8C-3cd0ca2b194d">#225 結合圖片、文字、button 的 SwiftUI State / UIKit IBAction / Flutter setState 練習題</a></p><h3>結語</h3><p>在這個「Random Food Picker」中，你會學到串好 <strong>Storyboard 介面</strong>、熟悉 <strong>IBOutlet / IBAction</strong>、練習 <strong>Array + Random</strong>，還能把 <strong>Assets</strong> 管理觀念一併打好基礎。</p><p>下次朋友問「今天吃什麼？」就把 App 打開 — — 讓機器幫你做最艱難的那個決定吧 🍕🍣🥗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1308754aaf12" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/07-random-food-picker-%E4%BB%8A%E5%A4%A9%E5%90%83%E4%BB%80%E9%BA%BC-%E7%94%A8-uikit-ibaction-%E5%B9%AB%E4%BD%A0%E6%B1%BA%E5%AE%9A-1308754aaf12">#07 Random Food Picker 今天吃什麼？ | 用 UIKit + IBAction 幫你決定</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#06 AI出題，利用 function 計算結果]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/06-ai%E5%87%BA%E9%A1%8C-%E5%88%A9%E7%94%A8-function-%E8%A8%88%E7%AE%97%E7%B5%90%E6%9E%9C-ba390290ba27?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba390290ba27</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Sun, 10 Aug 2025 06:16:28 GMT</pubDate>
            <atom:updated>2025-08-10T10:40:38.296Z</atom:updated>
            <content:encoded><![CDATA[<p>今天我們要學習的是 Swift 中的 <strong>function（函式）</strong>。</p><p>幾乎所有的程式語言都有函式的語法，而善用函式的好處非常多 — — 它可以幫我們省下重複撰寫相同程式碼的時間，也能將程式碼「打包」成容易閱讀、維護的模組。</p><p>這樣一來，當我們需要修改時，就不必在程式中東翻西找相同的片段，一個地方改好，其他地方就能直接套用，大幅提升效率與可讀性。</p><h3>AI出題</h3><h4>Question:</h4><p>出一題跟巧克力有關的 Swift function 練習題，在 function 裡印出計算的結果，寫出題目就好。</p><p>請寫一個 Swift 函數 calculateChocolatePrice，使用三個輸入參數 pricePerPound、ounces 和 discount，分別表示巧克力每磅的價格、巧克力的重量（單位為盎司）以及折扣百分比。在函數內部，請先計算出巧克力的總價格（未打折的價格），然後再根據折扣百分比計算出打折後的價格，並印出計算結果。</p><h3>function 應用</h3><pre>import UIKit<br><br>func calculateChocolatePrice(pricePerPound: Double, ounces: Double, discount: Double) {<br>    let ouncesPerPound: Double = 16<br>    let totalChocolatePrice = (ounces / ouncesPerPound) * pricePerPound<br>    let discountedChocolatePrice = totalChocolatePrice * (1 - (discount / 100))<br>    <br>//    print(&quot;Original Price: \(totalChocolatePrice)&quot;)<br>//    print(&quot;Discounted Price: \(discountedChocolatePrice)&quot;)<br>    print(String(format: &quot;Original Price: %.2f&quot;, totalChocolatePrice))<br>    print(String(format: &quot;Discounted Price: %.2f&quot;, discountedChocolatePrice))<br>}<br><br>calculateChocolatePrice(pricePerPound: 5, ounces: 32, discount: 20)</pre><p>完成function的程式後，之後要計算巧克力價格時，只需要呼叫這個 function 就行啦，輸入三個參數pricePerPound、ounces 和 discount ，就能得到巧克力的原始價格以及折扣後的價格。</p><p>上面的範例印出結果長這樣：</p><pre>Original Price: 10.00<br>Discounted Price: 8.00</pre><h3>GitHub URL</h3><p><a href="https://github.com/PolarBear1017/function_praction_chocolate">GitHub - PolarBear1017/function_praction_chocolate</a></p><h3>教學連結</h3><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/function-%E8%A3%A1%E5%8D%B0%E5%87%BA%E8%A8%88%E7%AE%97%E7%B5%90%E6%9E%9C%E7%9A%84%E9%A1%8C%E7%9B%AE-%E8%AB%8B-ai-%E5%87%BA%E9%A1%8C-e24cb489fad5">function 裡印出計算結果的題目 — 請 AI 出題</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba390290ba27" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/06-ai%E5%87%BA%E9%A1%8C-%E5%88%A9%E7%94%A8-function-%E8%A8%88%E7%AE%97%E7%B5%90%E6%9E%9C-ba390290ba27">#06 AI出題，利用 function 計算結果</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#05 各種有趣的 iOS SDK，播音樂、影片、地圖、網頁、時間、語音]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/05-%E5%90%84%E7%A8%AE%E6%9C%89%E8%B6%A3%E7%9A%84ios-sdk-%E6%92%AD%E9%9F%B3%E6%A8%82-%E5%BD%B1%E7%89%87-%E5%9C%B0%E5%9C%96-%E7%B6%B2%E9%A0%81-%E6%99%82%E9%96%93-%E8%AA%9E%E9%9F%B3-a8d6d477e7eb?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8d6d477e7eb</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Fri, 08 Aug 2025 03:11:12 GMT</pubDate>
            <atom:updated>2025-08-08T14:39:09.111Z</atom:updated>
            <content:encoded><![CDATA[<p>我們今天要學的是 iOS SDK，我覺得這個主題蠻有趣的，像是播音樂、影片、地圖、網頁、時間、語音，這些常常使用的APP功能，Apple 全部都幫你整理好在 SDK 裡面啦！那就讓我們一起來試試這些有趣的功能吧！</p><h3>用 AVPlayer 播音樂</h3><pre>// 用 AVPlayer 播音樂<br>import AVFoundation<br><br>let url = URL(string: &quot;https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview221/v4/68/d8/6d/68d86dde-7eb2-b75f-3a11-d7c8c8206733/mzaf_7547506640751628777.plus.aac.p.m4a&quot;)<br>let player = AVPlayer(url: url!)<br>player.play()</pre><p>result結果像是這樣，接著就聽得到你上傳的音樂啦！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bTJ-E5NaLtRnQIneRiMeJQ.png" /></figure><h4>iTunes API 歌曲查詢 (by Peter Pan)</h4><p>下面是 Peter 做的 API 查詢網站，打上歌曲名或歌手就能查詢歌曲的 API 資訊啦（搜尋不到歌曲時，可以把歌曲名跟歌手都打上去，會更準確）。</p><p><a href="https://flutter-itunes-search.web.app/?source=post_page-----1c10c80758a3---------------------------------------">flutter_application_1</a></p><h3>用 AVPlayerViewController 播影片</h3><p>目前用 Playground 播影片會有閃退的Bug，沒辦法測試。之後可以加進 App 裡再去執行。下面我一樣放上參考的程式。</p><pre>import AVKit<br>import PlaygroundSupport<br><br>let url = URL(string: &quot;https://video-ssl.itunes.apple.com/apple-assets-us-std-000001/Video128/v4/ac/7c/62/ac7c6274-60ea-5b7c-4c99-f08d78bfe574/mzvf_484000410198456586.640x352.h264lc.U.p.m4v&quot;)<br>let player = AVPlayer(url: url!)<br>let controller = AVPlayerViewController()<br>controller.player = player<br>PlaygroundPage.current.liveView = controller<br>player.play()</pre><h3>利用 SFSafariViewController 顯示網頁</h3><pre>// 利用 SFSafariViewController 顯示網頁<br>import SafariServices<br>import PlaygroundSupport<br><br>let url = URL(string: &quot;https://www.apple.com/&quot;)!<br>let controller = SFSafariViewController(url: url)<br>PlaygroundPage.current.liveView = controller</pre><p>在右側的 Live View 頁面就可以像在手機上瀏覽 Safari 一樣滑動、點選、操作。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DkOkJRYBQEB8Gp3Vu--6Dw.png" /></figure><h3>顯示地圖</h3><p>接著我們來使用地圖的功能啦 （使用的是 Apple 內建的 Maps），設定地圖範圍、標記想去的景點（使用經緯度），還可以打上自己想的 Title 和 Subtitle 。<br>下圖是東京晴空塔周圍的景點（最近在規劃去東京自由行！🥳）</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*pGcHZb8ZNNl1aLySV_7QYQ.png" /></figure><p>點一下景點，圖標就會出現可愛的放大動畫，也可以看到自己輸入的 Subtitle 喔，真的跟在操作 Maps 一模一樣😆。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*0kSllkpxzUZqr5X6i_WrEQ.png" /></figure><p>還可以變成衛星空拍影像地圖喔。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*5bY3dvxLqu8N1kuS6TSAbg.png" /></figure><h3>時間顯示</h3><p>設定現在時間</p><pre>import Foundation<br><br>var time = Date()   // 現在時間<br>print(time)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*Y83rj-RBaGQBMU3wk7RgzA.png" /></figure><p>設定顯示時間格式、時區</p><pre>let formatter = DateFormatter()<br>formatter.timeZone = TimeZone(identifier: &quot;Europe/London&quot;)    // 沒設定時區預設為使用者所在時區<br>formatter.dateFormat = &quot;yyyy/MM/dd HH:mm&quot;   // 設定時間格式<br>var dateString = formatter.string(from: time)<br>print(dateString)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*CRj5U9Q6YzMDrAeeKTPhCQ.png" /></figure><p>調整時間</p><pre>time.addTimeInterval(13820) // 增加秒數<br>print(time)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*WZRtuBGyHN4oSBDXUMByWg.png" /></figure><p>顯示時間詳細資訊</p><pre>let today = Date()<br>let dateComponous = Calendar.current.dateComponents(in: .current, from: today)<br>let month = dateComponous.month<br>let day = dateComponous.day<br>let year = dateComponous.year<br>let weekday = dateComponous.weekday // Sunday: 1, Monday: 2, ...</pre><p>iOS 13 的 RelativeDateTimeFormatter</p><pre>// iOS 13 的 RelativeDateTimeFormatter<br>time = Date.now.advanced(by: -70)   // 70 seconds ago<br>var relativeFormatter = RelativeDateTimeFormatter()<br>dateString = relativeFormatter.string(for: time)!<br>print(dateString)<br><br>time = Calendar.current.date(byAdding: .day, value: -8, to: .now)!  // 8 days ago<br>dateString = relativeFormatter.string(for: time)!<br>print(dateString)<br><br>time = Calendar.current.date(byAdding: .day, value: -32, to: .now)!<br>dateString = relativeFormatter.string(for: time)!<br>print(dateString)<br><br>time = Calendar.current.date(byAdding: .day, value: -380, to: .now)!    // 380 days ago<br>dateString = relativeFormatter.string(for: time)!<br>print(dateString)<br><br>time = Calendar.current.date(byAdding: .day, value: -8, to: .now)!<br>let components = Calendar.current.dateComponents([.day], from: time, to: .now)<br>if let day = components.day,<br>   day &gt; 7 {<br>    let formatter = DateFormatter()<br>    formatter.dateStyle = .medium<br>    formatter.timeZone = .none<br>    dateString = formatter.string(for: time)!<br>}<br>else {<br>    let formatter = RelativeDateTimeFormatter()<br>    dateString = formatter.string(for: time)!<br>}<br>print(dateString)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*dDq2TsLrdRUrmhJEgrW0Hw.png" /></figure><p>iOS 15 的 relative(presentation:unitsStyle:)</p><pre>// iOS 15 的 relative(presentation:unitsStyle:)<br>time = Calendar.current.date(byAdding: .day, value: -1, to: .now)!<br>dateString = time.formatted(.relative(presentation: .numeric))  // 顯示為數字,ex: 1 day ago<br><br>//dateString = time.formatted(.relative(presentation: .named))  // 顯示為文字,ex: yesterday<br>print(dateString)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/1*ak-0vZZ6d7dxfV5zC9ENyA.png" /></figure><h3>使用 AVSpeechSynthesizer 講話</h3><pre>import UIKit<br><br>// 使用 AVSpeechSynthesizer 講話<br>import AVFAudio<br><br>let utterance = AVSpeechUtterance(string: &quot;Hi every one&quot;)<br>//utterance.voice = AVSpeechSynthesisVoice(language: &quot;zh-TW&quot;) // 切換說話語言<br>utterance.rate = 0.7  // 語速<br>utterance.pitchMultiplier = 1 // 音調<br>let synthesier = AVSpeechSynthesizer()<br>synthesier.speak(utterance)</pre><p>學會這些元件，是不是挺有趣的呀！😁 有了這些元件就可以做很多有趣的App啦！</p><h3>GitHub URL</h3><p><a href="https://github.com/PolarBear1017/iOS_SDK">GitHub - PolarBear1017/iOS_SDK: 利用 iOS SDK 各式型別生成東西，設定它的屬性和呼叫方法</a></p><h3>教學網址</h3><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/%E5%88%A9%E7%94%A8-ios-sdk-%E5%90%84%E5%BC%8F%E5%9E%8B%E5%88%A5%E7%94%9F%E6%88%90%E6%9D%B1%E8%A5%BF-%E8%A8%AD%E5%AE%9A%E5%AE%83%E7%9A%84%E5%B1%AC%E6%80%A7%E5%92%8C%E5%91%BC%E5%8F%AB%E6%96%B9%E6%B3%95-1c10c80758a3">#42 利用 iOS SDK 各式型別生成東西，設定它的屬性和呼叫方法</a></p><h4>地圖教學</h4><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/ios-sdk-%E9%A1%AF%E7%A4%BA%E5%9C%B0%E5%9C%96-%E5%9C%B0%E5%9C%96%E6%A8%99%E8%A8%98%E7%9A%84%E6%96%B9%E6%B3%95-7b284e48a446">iOS SDK 顯示地圖 &amp; 地圖標記的方法</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8d6d477e7eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/05-%E5%90%84%E7%A8%AE%E6%9C%89%E8%B6%A3%E7%9A%84ios-sdk-%E6%92%AD%E9%9F%B3%E6%A8%82-%E5%BD%B1%E7%89%87-%E5%9C%B0%E5%9C%96-%E7%B6%B2%E9%A0%81-%E6%99%82%E9%96%93-%E8%AA%9E%E9%9F%B3-a8d6d477e7eb">#05 各種有趣的 iOS SDK，播音樂、影片、地圖、網頁、時間、語音</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#04 用 Swift 程式自製一張卡片]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/04-%E7%94%A8swift%E7%A8%8B%E5%BC%8F%E8%87%AA%E8%A3%BD%E4%B8%80%E5%BC%B5%E5%8D%A1%E7%89%87-f4b188ca98b9?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4b188ca98b9</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Sat, 02 Aug 2025 04:07:26 GMT</pubDate>
            <atom:updated>2025-08-08T03:15:03.243Z</atom:updated>
            <content:encoded><![CDATA[<p>這次我們要使用 Swift 程式的語法，搭配一些 UI 的功能（有使用的功能我一樣放在下面介紹），以及程式的操作，做出一張自製的卡片。</p><h4>先來複習一些使用到的功能、語法</h4><ol><li>UIImage</li><li>UIImageView</li><li>layer</li><li>UILable</li><li>function</li><li>CGAffineTransform — 控制圖片旋轉、縮放、位移</li><li>addSubview — 在某個 View上面加上 View (稱為 subview)</li><li>viewDidLoad — 當App畫面載入時的動作</li></ol><h3>成果圖片</h3><ul><li>加入狗狗圖片、調整大小與邊框、設定邊框圓角、加入星星Emoji、用 addSubview 來加在狗狗圖片的上面</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_hAFiUNiu0anc4dfoK9Kng.png" /></figure><ul><li>使用function的方式來加入多個星星，並個別設定位置以及旋轉角度</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqBaB0hIXdm1g0r03fxtgQ.png" /></figure><ul><li>輸入文字、一樣使用 addSubview 來加在狗狗圖片的上面，大功告成</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tbcdD-sVymMK9VtNdeefeA.png" /></figure><p>利用 Swift 程式自製的卡片就完成啦！</p><h3>GitHub連結</h3><p><a href="https://github.com/PolarBear1017/design_interesting_image">GitHub - PolarBear1017/design_interesting_image</a></p><h3>教學連結</h3><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/142-%E4%BD%BF%E7%94%A8%E5%9C%96%E7%89%87-%E6%96%87%E5%AD%97-emoji-%E9%82%8A%E6%A1%86-%E5%9C%93%E8%A7%92%E8%A3%BD%E4%BD%9C%E6%BC%82%E4%BA%AE%E5%8D%A1%E7%89%87-401741bf23f7"># 142 使用圖片，文字，emoji，邊框 &amp; 圓角製作漂亮卡片</a></p><h3>心得</h3><p>在做這個項目的時候不確定是不是 Beta 版的 bug，在執行 Simulator 的時候好幾次電腦一直突然當掉重新開機，後面寫的東西就不見了（幸好沒有全部消失，不然真的會哭🥲），過程中幾經波折，不過在好幾次的重新開機與復原中，最後終於完成這個專案了，特別的感動🥹！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4b188ca98b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/04-%E7%94%A8swift%E7%A8%8B%E5%BC%8F%E8%87%AA%E8%A3%BD%E4%B8%80%E5%BC%B5%E5%8D%A1%E7%89%87-f4b188ca98b9">#04 用 Swift 程式自製一張卡片</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#03 用 Scroll View (水平捲動，上下捲動、分頁) 做一個狗狗配件搭配App]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/03-%E7%94%A8scroll-view-%E6%B0%B4%E5%B9%B3%E6%8D%B2%E5%8B%95-%E4%B8%8A%E4%B8%8B%E6%8D%B2%E5%8B%95-%E5%88%86%E9%A0%81-%E5%81%9A%E4%B8%80%E5%80%8B%E7%8B%97%E7%8B%97%E9%85%8D%E4%BB%B6%E6%90%AD%E9%85%8Dapp-1abfb7999823?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1abfb7999823</guid>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 04:03:26 GMT</pubDate>
            <atom:updated>2025-08-08T03:15:37.557Z</atom:updated>
            <content:encoded><![CDATA[<p>這次我們要使用的是能夠讓畫面水平捲動，上下捲動以及分頁功能的Scroll View。利用滑動的方式來為狗狗搭配配件吧！</p><h3>成果展示</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FSoDAJU6e-Rs7b2LzA4UnQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAFgfUrU-24tD1yKWpWCrQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XYVcNNEP2LcFhTZ-oevRaA.png" /></figure><h3>成果影片</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*ppZ6XkNpI7tcuxcZvrEooQ.gif" /></figure><h4>GitHub連結</h4><p><a href="https://github.com/PolarBear1017/scroll_view">GitHub - PolarBear1017/scroll_view</a></p><h4>教學連結</h4><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/%E5%9C%A8-storyboard-%E8%A8%AD%E5%AE%9A-content-size-%E5%AF%A6%E7%8F%BE%E6%B0%B4%E5%B9%B3%E6%8D%B2%E5%8B%95%E7%9A%84-scroll-view-2710fa247293">設定 content size，實現水平捲動，上下捲動和分頁的 scroll view</a></p><h4>參考連結</h4><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/ios%E5%AD%B8%E7%BF%9203-%E5%AF%A6%E7%8F%BE%E6%B0%B4%E5%B9%B3%E6%8D%B2%E5%8B%95-%E4%B8%8A%E4%B8%8B%E6%8D%B2%E5%8B%95%E5%92%8C%E5%88%86%E9%A0%81%E7%9A%84-scroll-view-6c2c9d58acdb">IOS學習02|實現水平捲動，上下捲動和分頁的 scroll view</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1abfb7999823" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/03-%E7%94%A8scroll-view-%E6%B0%B4%E5%B9%B3%E6%8D%B2%E5%8B%95-%E4%B8%8A%E4%B8%8B%E6%8D%B2%E5%8B%95-%E5%88%86%E9%A0%81-%E5%81%9A%E4%B8%80%E5%80%8B%E7%8B%97%E7%8B%97%E9%85%8D%E4%BB%B6%E6%90%AD%E9%85%8Dapp-1abfb7999823">#03 用 Scroll View (水平捲動，上下捲動、分頁) 做一個狗狗配件搭配App</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#02 常見 UI 元件介紹]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/2-%E5%B8%B8%E8%A6%8Bui%E5%85%83%E4%BB%B6%E4%BB%8B%E7%B4%B9-6d7a43a1d0cb?source=rss-8f6efc1743ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d7a43a1d0cb</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[storyboard]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Hui Fan]]></dc:creator>
            <pubDate>Fri, 25 Jul 2025 04:03:41 GMT</pubDate>
            <atom:updated>2025-08-08T03:15:59.778Z</atom:updated>
            <content:encoded><![CDATA[<p>今天介紹各種常見的 Xcode App UI components。我做了一個App讓大家可以實際操作探索介紹的元件，可以像是一般的App元件那樣去滑動、選擇…。順便也複習了一下之前教的內容、用法，有使用到的內容我打在下面，可供參考。也順便使用到電子書HW的功能應用。</p><h4>複習之前教的內容：</h4><ul><li>Navigation Controller</li><li>Table View Controller, Table View</li><li>Tab Bar Controller, Tab Bar</li><li>storyboard reference</li><li>Image View</li></ul><h4>作業來源🔗：</h4><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E7%A0%94%E7%A9%B6%E4%BB%A5%E4%B8%8B-ui-%E5%85%83%E4%BB%B6-segmented-control-slider-switch-activity-indicator-view-progress-view-page-control-date-71acc5b2dd7e">研究以下 UI 元件: Segmented Control，Slider，Switch，Activity Indicator View，Progress View，Page Control</a></li><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/storyboard-%E9%9B%BB%E5%AD%90%E6%9B%B8-app-%E6%90%AD%E9%85%8D-tab-controller-table-controller-navigation-controller-%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-ios-app-%E4%BD%9C%E6%A5%AD-aaa7e5f9165e">#24 Storyboard 電子書 App</a></li></ul><h4>參考文章</h4><p>這篇內容有引用了<a href="https://medium.com/@peichi?source=post_page---byline--b95d33395295---------------------------------------">Pei-chi</a>的這篇文章，非常感謝他，真的整理得很詳細、很實用！</p><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E4%BD%9C%E6%A5%AD-3-%E7%A0%94%E7%A9%B6%E5%90%84%E7%A8%AE-ui-%E5%85%83%E4%BB%B6-b95d33395295">作業#3 — 研究各種 UI 元件</a></p><p>以及好讀可放大的Xmind網頁版：</p><p><a href="https://xmind.app/m/t5ytTx/?source=post_page-----b95d33395295---------------------------------------">UI Components Research</a></p><p>那麼就開始我們今天的主題吧。</p><p>今天我們要介紹的UI components：</p><ul><li>Segmented Control — 切換分類的元件</li><li>Slider — 滑動設定數值的元件</li><li>Switch — 開關</li><li>Activity Indicator View — 轉圈圈，loading 中的圖示</li><li>Progress View — 顯示進度的進度條</li><li>Visual Effect View with Blur — 毛玻璃效果</li><li>Page Control — 顯示分頁的小圓點，顯示有幾個分頁與目前所在分頁。</li><li>Date Picker — 選擇時間</li><li>Color Well — 選擇顏色</li></ul><p>（可能因為用的Xcode Beta 版還有些bugs，所以在測試時 Segmented Control 和 Date Picker 顯示是異常的，以下可能就沒辦法作詳細說明）</p><p>下面是我的main.storyboard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nUyJB7qtw37T6hejbiGR1g.png" /></figure><p>每個cell點進去能夠切換 Tab bar 的功能</p><ol><li>Try — 與元件互動</li><li>Information — 查看相關元件的功能設定</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*rYAD-tFZKcWHcmK27Tzugw.png" /></figure><h4>App 操作影片</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*MlEaMThoX_0wAQp460QUFg.gif" /></figure><h4>App icon</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/176/1*PH3vXASTAn41dqNTY3C97Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I2fnCFIX_ozd40En-F92Bg.png" /></figure><p>GitHub URL🔗:</p><p><a href="https://github.com/PolarBear1017/comment_UI_components">GitHub - PolarBear1017/comment_UI_components</a></p><p>心得：</p><p>這次在做 App 的時候才發現，拉 storyboard 真的沒有想像中簡單，不只要細心，還得有耐心跟毅力。雖然有點小挫折，但也剛好讓我把之前學過的功能又重新複習了一遍，感覺像是在幫自己打好基礎，準備好再往下一步邁進。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d7a43a1d0cb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/2-%E5%B8%B8%E8%A6%8Bui%E5%85%83%E4%BB%B6%E4%BB%8B%E7%B4%B9-6d7a43a1d0cb">#02 常見 UI 元件介紹</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>