<?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 Jess Hsu on Medium]]></title>
        <description><![CDATA[Stories by Jess Hsu on Medium]]></description>
        <link>https://medium.com/@huishuan?source=rss-7c5708eec05------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2OwNLgPeZs1janU6nXCNvg.jpeg</url>
            <title>Stories by Jess Hsu on Medium</title>
            <link>https://medium.com/@huishuan?source=rss-7c5708eec05------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 03:31:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@huishuan/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[#12 猜猜我幾歲?]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/12-%E7%8C%9C%E7%8C%9C%E6%88%91%E5%B9%BE%E6%AD%B2-31653e95f818?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/31653e95f818</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Sun, 12 Sep 2021 12:10:25 GMT</pubDate>
            <atom:updated>2021-09-12T12:34:14.123Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhvR_mYIX1HfXN_eSWAwSw.jpeg" /></figure><p>大家都說<strong>年齡是女人的秘密</strong>，現代社會更注重保養下誕生出許多美魔女，看似少女般的外表下沒人能看出她們的年齡。</p><p>這次的作業要利用class、property &amp; method 來製作猜數字 App，一起來猜猜看，眼前的女生實際年齡到底幾歲。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*dLt_nU3IIliRFujvwnfGAA.gif" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FScVRNoEYJhM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DScVRNoEYJhM&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eeb718e2c2f83463f6a661c1b28db3cd/href">https://medium.com/media/eeb718e2c2f83463f6a661c1b28db3cd/href</a></iframe><p>Github：</p><p><a href="https://github.com/jesshsu23/number">GitHub - jesshsu23/number</a></p><p>參考：</p><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/%E7%8C%9C%E6%95%B8%E5%AD%97-app-%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-ios-app-%E4%BD%9C%E6%A5%AD-7a17771304a7">#6 猜數字 和 1A2B App</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31653e95f818" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/12-%E7%8C%9C%E7%8C%9C%E6%88%91%E5%B9%BE%E6%AD%B2-31653e95f818">#12 猜猜我幾歲?</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[#11 調色大師：搭配完美情侶裝，閃爆單身狗]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/11-%E8%AA%BF%E8%89%B2%E5%A4%A7%E5%B8%AB-%E6%90%AD%E9%85%8D%E5%AE%8C%E7%BE%8E%E6%83%85%E4%BE%B6%E8%A3%9D-%E9%96%83%E7%88%86%E5%96%AE%E8%BA%AB%E7%8B%97-4ed20c4f33da?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ed20c4f33da</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Mon, 30 Aug 2021 17:51:32 GMT</pubDate>
            <atom:updated>2021-08-31T03:02:22.467Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Al8mPuyyfwYwaMc-K3hapw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@sebastianmark?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sebastian Mark</a> on <a href="https://unsplash.com/s/photos/couples?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>擺脫一成不變的風格</h4><p>俗話說「愛你所擇，擇你所愛」，但有時候時間一久，再愛的也會膩，當初確定的也會開始不知道該如何選擇（我是說衣服）。</p><p>於是這次的作業我們要利用<strong>RGB CGFloat</strong>及<strong>亂數</strong>來練習調色，在約會前，透過情侶裝選擇器App，找出穿衣的靈感。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbjrqgLQjrLaDoIsyZ_sQA.jpeg" /></figure><h4>步驟一：畫面製作</h4><p>由於這週比較忙，沒有時間自己做素材，於是我直接從網路上找喜歡的插圖以及背景，把想換顏色的地方去背。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GgkUFkGM0tpZqwN1CBZjow.jpeg" /><figcaption>來源：<a href="https://www.pinterest.com/pin/848787861015016155/">https://www.pinterest.com/pin/848787861015016155/</a></figcaption></figure><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%A6%82%E4%BD%95%E7%94%A8-previe-app-%E9%A0%90%E8%A6%BD%E7%A8%8B%E5%BC%8F-%E5%8E%BB%E8%83%8C%E5%9C%96%E7%89%87-f44640424ba2">如何用 Preview App (預覽程式)去背圖片</a></p><p>放上Xcode後把背景調成白色。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*weTsxN0prmR1XnWypMlJ7A.png" /></figure><p>加上Slide後，把值都調成1。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1FRlJitWxDI_UOi7ljShEg.png" /></figure><h4>步驟二：action</h4><p>有了RGB及透明度Slide後，因為它們的功能類似，於是在拉action時，可以將四個合併成一組。</p><pre>@IBAction func changeColor(_ sender: Any) {</pre><pre>}</pre><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%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></p><h4>步驟三：outlet</h4><p>但是在outlet這邊，由於需要讀取 4 個 slider 的 value，所以總共需要拉 5 個outlet，才能從程式存取所有數值。</p><p>在這個作業的範例中更可以看到，有時候同一個元件可能既拉 outlet ，也拉 action。</p><pre>@IBOutlet weak var coupleImageView: UIImageView!</pre><pre>@IBOutlet weak var redSlider: UISlider!</pre><pre>@IBOutlet weak var greenSlider: UISlider!</pre><pre>@IBOutlet weak var blueSlider: UISlider!</pre><pre>@IBOutlet weak var alphaSlider: UISlider!</pre><h4>步驟四：程式</h4><p>拉完線後，在changeColor的action中寫程式，由於型別不同，所以這邊要使用CGFloat而不是Float。</p><p>錯誤：</p><pre>@IBAction func changeColor(_ sender: Any) {</pre><pre>coupleImageView.backgroundColor = UIColor(red:</pre><pre>redSlider.value, green: greenSlider.value, blue:</pre><pre>blueSlider.value, alpha: alphaSlider.value)</pre><pre>}</pre><p>正確：</p><pre>@IBAction func changeColor(_ sender: Any) {</pre><pre>coupleImageView.backgroundColor = UIColor(red:</pre><pre>CGFloat(redSlider.value), green: CGFloat(greenSlider.value), blue:</pre><pre>CGFloat(blueSlider.value), alpha: CGFloat(alphaSlider.value))</pre><pre>}</pre><h4>步驟五：亂數</h4><p>因為調到最後心會很累，所以在App中加入隨機調色的功能。</p><pre>@IBAction func randomColor(_ sender: Any) {</pre><pre>redSlider.value = Float.random(in: 0…1)</pre><pre>greenSlider.value = Float.random(in: 0…1)</pre><pre>blueSlider.value = Float.random(in: 0…1)</pre><pre>alphaSlider.value = Float.random(in: 0.5…1)</pre><pre>coupleImageView.backgroundColor = UIColor(red:</pre><pre>CGFloat(redSlider.value), green: CGFloat(greenSlider.value),</pre><pre>blue: CGFloat(blueSlider.value), alpha:</pre><pre>CGFloat(alphaSlider.value))</pre><pre>}</pre><h4>完成</h4><p>開始搭配你的完美情侶裝，閃爆那些單身狗吧！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*ydeko9S12oGwNp-ERjASaA.gif" /></figure><p>程式碼：</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c281a52be1da28b7123df4f94a40bff/href">https://medium.com/media/8c281a52be1da28b7123df4f94a40bff/href</a></iframe><p>Github:</p><p><a href="https://github.com/jesshsu23/ColorAPP">GitHub - jesshsu23/ColorAPP</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ed20c4f33da" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/11-%E8%AA%BF%E8%89%B2%E5%A4%A7%E5%B8%AB-%E6%90%AD%E9%85%8D%E5%AE%8C%E7%BE%8E%E6%83%85%E4%BE%B6%E8%A3%9D-%E9%96%83%E7%88%86%E5%96%AE%E8%BA%AB%E7%8B%97-4ed20c4f33da">#11 調色大師：搭配完美情侶裝，閃爆單身狗</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 利用AVSpeechSynthesizer講出開不了口的告白]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/10-%E5%88%A9%E7%94%A8avspeechsynthesizer%E8%AC%9B%E5%87%BA%E9%96%8B%E4%B8%8D%E4%BA%86%E5%8F%A3%E7%9A%84%E5%91%8A%E7%99%BD-7ff8f108f2e1?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ff8f108f2e1</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Wed, 25 Aug 2021 10:25:52 GMT</pubDate>
            <atom:updated>2021-08-25T11:55:25.910Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R3qejQJXEBY7VfZg11AOOg.jpeg" /></figure><blockquote>情人節沒人陪你一起度過？也沒有任何人跟你告白嗎？</blockquote><blockquote>沒關係，可以使用「開不了口的告白」App，體驗一次被三個不同國籍的女朋友告白的美好感覺！</blockquote><p>這次的練習是使用AVFoundation，在輸入框中打出文字，並自由選擇中、英、日三種不同語言，按下按鈕，App就會自動唸出輸入的文字。</p><p>本來預計在七夕時做好，但畫圖＋第一次做outlet＆action實在是卡關太久了，所以拖到現在。不過沒關係，有你在的日子天天都是情人節！</p><p>PS：本來是想做男朋友的，可惜蘋果只有女聲..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*WEwYMFpQUQL6OA6FdTgKpQ.gif" /></figure><h4>步驟1 — 拉出outlet＆action</h4><p>排好畫面後，將輸入框及Slide拉線到上方outlet的位置，而需要被觸發的Button拉到下方action。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xQDNtz9vvWSRuv3D84_jsQ.png" /></figure><pre>import UIKit</pre><pre>import AVFoundation<br></pre><pre>class ViewController: UIViewController {</pre><pre>//輸入文字</pre><pre>@IBOutlet weak var TextField: UITextField!</pre><pre>//聲音</pre><pre>@IBOutlet weak var volumeSlider: UISlider!</pre><pre>@IBOutlet weak var rateSlider: UISlider!</pre><pre><br>override func viewDidLoad() {</pre><pre>super.viewDidLoad()</pre><pre>}<br></pre><pre>//女朋友</pre><pre>@IBAction func AmericanGirlfriend(_ sender: Any) {</pre><pre>}</pre><pre>@IBAction func JapanGirlfriend(_ sender: Any) {</pre><pre>}</pre><pre>@IBAction func TaiwanGrilfriend(_ sender: Any){ </pre><pre>}</pre><pre>}</pre><p>參考資料：</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/%E9%80%A3%E7%B5%90-iboutlet-%E5%92%8C-ibaction-%E7%9A%84%E6%AD%A5%E9%A9%9F%E8%AA%AA%E6%98%8E-f647f07329ad">連結 IBAction 和 IBOutlet 的步驟說明</a></p><h4>步驟2— AVFoundation</h4><p>使用AVFoundation的功能做出合成器，因為三個Button除了語言外的動作是一樣的，所以寫成funtion，並在每個Button中加上不同的參數。</p><pre>//女朋友</pre><pre>func girlfriend(language: String){</pre><pre>let speechUtterance =  AVSpeechUtterance(string: TextField.text!)</pre><pre>speechUtterance.voice = AVSpeechSynthesisVoice(language: language)</pre><pre>let synthesizer = AVSpeechSynthesizer()</pre><pre>speechUtterance.rate = rateSlider.value</pre><pre>speechUtterance.volume = volumeSlider.value</pre><pre>synthesizer.speak(speechUtterance)</pre><pre>}</pre><pre>@IBAction func AmericanGirlfriend(_ sender: Any) {</pre><pre>girlfriend(language:&quot;en-US&quot; )</pre><pre>}</pre><pre>@IBAction func JapanGirlfriend(_ sender: Any) {</pre><pre>girlfriend(language:&quot;ja-JP&quot; )</pre><pre>}</pre><pre>@IBAction func TaiwanGrilfriend(_ sender: Any){ girlfriend(language:&quot;zh-TW&quot; )</pre><pre>}</pre><h4>步驟3—消除Bug</h4><p>明明把程式寫好，模擬器卻不能跑，原來是發生了新手常見的bug！因為重新調整很多次的關係，所以有些outlet或action找不到對應的元件，造成App閃退，顯錯誤訊息如下：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iaA6WYIKA0bVR2kVqQNeGQ.png" /></figure><p>解決方式：</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/outlet-%E6%88%96-action-%E6%89%BE%E4%B8%8D%E5%88%B0%E9%80%A3%E7%B7%9A%E7%9B%AE%E6%A8%99-%E9%80%A0%E6%88%90-app-%E9%96%83%E9%80%80-7056edbc9ff3">outlet 或 action 找不到連線目標，造成 App 閃退</a></p><h4>完成品</h4><p>完成了！因為這次的作業用到許多才剛學的程式邏輯去做結合，短短幾行code就卡關了超級久，但做好之後成就感十足，以後就算沒人陪也不會孤單寂寞覺得冷拉～(´∀｀)♡</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaqgZmVzYPkY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaqgZmVzYPkY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FaqgZmVzYPkY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c5ceb3ccc2fec8a419c46768895df6a/href">https://medium.com/media/8c5ceb3ccc2fec8a419c46768895df6a/href</a></iframe><p>程式碼：</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7184024bcd96acda457ee3fc85a1af96/href">https://medium.com/media/7184024bcd96acda457ee3fc85a1af96/href</a></iframe><p>GitHub：</p><p><a href="https://github.com/jesshsu23/Speak-app">GitHub - jesshsu23/Speak-app</a></p><p>參考文章：</p><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/55-%E9%96%8B%E4%B8%8D%E4%BA%86%E5%8F%A3%E7%9A%84%E5%91%8A%E7%99%BD-app-15198735161f">#55 開不了口的告白 &amp; 我們一起學貓叫</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ff8f108f2e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/10-%E5%88%A9%E7%94%A8avspeechsynthesizer%E8%AC%9B%E5%87%BA%E9%96%8B%E4%B8%8D%E4%BA%86%E5%8F%A3%E7%9A%84%E5%91%8A%E7%99%BD-7ff8f108f2e1">#10 利用AVSpeechSynthesizer講出開不了口的告白</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[＃9利用 iOS SDK 各式型別生成東西，設定它的屬性和呼叫方法]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/9%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-7920c56b95a1?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/7920c56b95a1</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Mon, 09 Aug 2021 14:09:53 GMT</pubDate>
            <atom:updated>2021-08-09T14:35:41.162Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Bm0v4n9-1tHJi5Mc-kVig.jpeg" /><figcaption>Photo by <br><a href="https://unsplash.com/@mailchimp/likes">Mailchimp</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>這次要來練習使用別人寫的指令(function)，也就是Apple 的 iOS SDK，第三方套件，提供我們開發程式會用到的功能，例如地圖、錄音。</p><ul><li>地圖: MapKit，MKMapView，MKCoordinateRegion</li><li>播音樂: AVFoundation，URL，AVPlayer</li><li>播影片: AVKit，AVPlayerViewController</li><li>網頁: SafariServices，SFSafariViewController</li><li>時間: Foundation，Date，DateFormatter，Calendar，DateComponents，Void</li><li>App 講話: AVFoundation，AVSpeechSynthesizer，AVSpeechUtterance，AVSpeechSynthesisVoice</li><li>playground: PlaygroundSupport，PlaygroundPage，liveView，type property</li></ul><p>首先先釐清邏輯</p><ol><li>生東西/取名＋型別＋（）</li></ol><p>就像我們要完成一件事，要先生出 <strong>人</strong>、<strong>動作</strong>與<strong>動作內容</strong></p><pre>var number = Int()</pre><pre>var emptyMessage = String()</pre><pre>var cuteBaby = Baby()</pre><p>例：</p><pre>let speechUtterance = AVSpeechUtterance(string: “i just can’t say it to let her know i will take care of you and make you laugh”)</pre><p>2.認臉</p><p>使用 iOS SDK 定義的東西，或使用第三方套件時需要加入<strong>import</strong>，讓xcode認出這個套件，在 project 裡使用自己定義的東西時則不用</p><p>例：使用 <strong>AVFoundation 這個</strong> iOS SDK</p><pre>import AVFoundation</pre><p>3.生出工具</p><p>人要靠工具才能做事，於是要生出工具</p><p>例：Synthesizer合成器</p><pre>let synthesizer = AVSpeechSynthesizer()</pre><p>4.叫工具做事</p><p>呼叫 function speak</p><pre>synthesizer.speak(speechUtterance)</pre><p>程式碼全文：</p><pre>import AVFoundation<br> <br>let speechUtterance = AVSpeechUtterance(string: “i just can’t say it to let her know i will take care of you and make you laugh”)<br>let synthesizer = AVSpeechSynthesizer()<br>synthesizer.speak(speechUtterance)</pre><h4>地圖</h4><p>打算利用地圖功能標記我最常去的地方，一開始為了使用顯示地圖的 MKMapView，所以必須import MapKit，另外為了在 playground 看到地圖，也須使用PlaygroundPage 的 liveView，因此也要 import PlaygroundSupport。</p><p>型別MKCoordinateRegion可控制地圖中心點的經緯度和範圍，裡面的數值分別為：</p><ul><li>center: 型別 CLLocationCoordinate2D，代表地圖中心點的經緯度座標。latitude 是緯度，longitude 是經度。</li><li>latitudinalMeters: 緯度範圍，單位是公尺，傳入 500 表示地圖的最北邊 &amp; 最南邊距離 500 公尺</li><li>longitudinalMeters: 經度範圍，單位是公尺，傳入 500 表示地圖的最東邊 &amp; 最西邊距離 500 公尺。</li></ul><p>Xcode playground 的 liveView 可以顯示某個 controller 或某個 view 的畫面，讓我們不用啟動模擬器，就能在 App 畫面上操作進行互動，快速地實驗 App 的相關功能。</p><p>最後用MKPointAnnotation 加入地圖標記。</p><pre>import MapKit</pre><pre>import PlaygroundSupport<br></pre><pre>//地圖範圍</pre><pre>let mapView = MKMapView(frame:CGRect(x: 0, y: 0, width: 300, height: 300))</pre><pre>mapView.region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 25.033493, longitude: 121.564101), latitudinalMeters: 1000, longitudinalMeters: 1000)</pre><pre>PlaygroundPage.current.liveView = mapView<br></pre><pre>//地圖標記</pre><pre>let Taipei101 = MKPointAnnotation()</pre><pre>Taipei101.title = “台北101”</pre><pre>Taipei101.coordinate = CLLocationCoordinate2D(latitude: 25.033493, longitude: 121.564101)</pre><pre>Taipei101.subtitle = “台灣難波萬”</pre><pre>mapView.addAnnotation(Taipei101)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*bahJmI3cSVrKA-UZ7Grb7g.png" /></figure><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><h4>播音樂</h4><p>AVFoundation ：播放音樂元件</p><p>加入URL ：音樂播放網址</p><ul><li><a href="https://getvideo.org/en">GetVideo - download videos from YouTube, download youtube</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%9F%A5%E8%A9%A2-itunes-%E9%9F%B3%E6%A8%82%E9%9B%BB%E5%BD%B1%E7%9A%84-preview-%E9%80%A3%E7%B5%90-c1bbe3285325">查詢 iTunes 音樂電影的 preview 連結</a></li><li><a href="https://www.yt2mp3.ws/">YouTube To MP3 - Free &amp; Fast Online Converter</a></li></ul><pre>import AVFoundation</pre><pre>let url=URL(string: &quot;https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview125/v4/e7/ba/51/e7ba51e4-11ae-da4b-5ee3-e2550c14dd3c/mzaf_14379985924893258217.plus.aac.p.m4a&quot;)</pre><pre>let player=AVPlayer(url: url!)</pre><pre>player.play()</pre><h4><em>播放影片</em></h4><p>AVKit ：播放影片</p><p>PlaygroundSupport ：讓playground可以顯示view</p><pre>import AVKit</pre><pre>import PlaygroundSupport</pre><pre>let url = URL(string: &quot;https://movietrailers.apple.com/movies/marvel/black-widow/black-widow-big-game-spots_h480p.mov&quot;)</pre><pre>let player=AVPlayer(url: url!)</pre><pre>let controller = AVPlayerViewController()</pre><pre>controller.player = player</pre><pre>PlaygroundPage.current.liveView = controller</pre><pre>player.play()</pre><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%88%A9%E7%94%A8-xcode-playground-%E7%9A%84-live-view-%E9%A1%AF%E7%A4%BA-controller-f9b20591857f">利用 Xcode playground 的 live view 顯示 App 畫面</a></p><h4>顯示網頁</h4><p>SafariServices → 開啟safar （沒有google服務），連到我的粉專。</p><pre>import SafariServices</pre><pre>import PlaygroundSupport</pre><pre>let url = URL(string: “https://www.facebook.com/A4concept&quot;)</pre><pre>let controller = SFSafariViewController(url: url!)</pre><pre>PlaygroundPage.current.liveView = controller</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*3uvqU6fUmjBoPS3rs4QDZA.png" /></figure><h4>列印時間</h4><p>利用Foundation 定義時間的項目，Date() 代表現在的時間（英國時區），在addTimeInterval()的括號中加上數字，代表增加的秒數。</p><pre>import Foundation</pre><pre>var time = Date()</pre><pre>print(time)</pre><pre>time.addTimeInterval(100)</pre><pre>print(time)</pre><h4>將時間變成特定格式的字串</h4><p>DateFormatter 可設定時間顯示的格式，yyyy，MM，dd 等時間格式的說明，可參考以下連結：</p><p><a href="https://nsdateformatter.com/">NSDateFormatter.com - Live Date Formatting Playground for Swift</a></p><pre>import Foundation</pre><pre>let now = Date()</pre><pre>let dateFormatter = DateFormatter()</pre><pre>dateFormatter.dateFormat = “MM/dd/yyyy”</pre><pre>let dateString = dateFormatter.string(from: now)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*r42weQG81TEvjcOb0QiM-Q.png" /></figure><h4>取得今天幾月幾號</h4><p>利用 Calendar.current 取得現在的月曆，然後呼叫它的 function dateComponents。</p><pre>import Foundation</pre><pre>let today = Date()</pre><pre>let dateComponents = Calendar.current.dateComponents(in: TimeZone.current, from: today)</pre><pre>let month = dateComponents.month</pre><pre>let day = dateComponents.day</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*haBD3kMrGvzDtYZs4CMVxA.png" /></figure><p>其他DateComponents 資料：</p><ul><li><a href="https://developer.apple.com/documentation/foundation/calendar/2293477-datecomponents">dateComponents(in:from:) | Apple Developer Documentation</a></li><li><a href="https://developer.apple.com/documentation/foundation/datecomponents">DateComponents | Apple Developer Documentation</a></li><li><a href="https://developer.apple.com/documentation/foundation/nsdatecomponents/1410442-weekday">weekday | Apple Developer Documentation</a></li></ul><h4>讓App 講話</h4><p>在AVSpeechUtterance 打上要講的話，AVSpeechSynthesisVoice 可以控制講話聲音的語言，AVSpeechSynthesizer 是發出聲音的合成器。</p><p>speechUtterance.rate可以調整講話速度，speechUtterance.pitchMultiplier可以調整講話的音調。</p><pre>import AVFoundation</pre><pre>let speechUtterance = AVSpeechUtterance(string:”就是開不了口，讓她知道。我一定會呵護著妳，也逗妳笑。”)</pre><pre>speechUtterance.voice = AVSpeechSynthesisVoice(language: “zh-TW”)</pre><pre>speechUtterance.rate = 0.5</pre><pre>speechUtterance.pitchMultiplier = 1</pre><pre>let synthesizer = AVSpeechSynthesizer()</pre><pre>synthesizer.speak(speechUtterance)</pre><p>參考資料：</p><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><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7920c56b95a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/9%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-7920c56b95a1">＃9利用 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[＃8使用圖片，文字，emoji，邊框 & 圓角製作長輩圖]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/8%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%E9%95%B7%E8%BC%A9%E5%9C%96-2dd22332330e?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dd22332330e</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Sun, 01 Aug 2021 17:43:01 GMT</pubDate>
            <atom:updated>2021-08-02T14:52:15.582Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pZ53P475foibucPwl6x4Zw.jpeg" /></figure><h4><strong>工作再忙，也要跟你來一張長輩圖</strong></h4><p>曾經看過一篇報導，令很多年輕人感到困擾的<strong>長輩圖</strong>，其實一開始是來自於社區的長青電腦製圖班，在課堂上長輩們會學習簡單的電腦操作，只要放上風景照或者生活照，打字上去，就能夠做出一張圖，而對長輩來說，他們的人際關係網絡就是家人，這也是為什麼你會一直收到長輩圖。</p><p>學了程式之後，能做的事也越來越多了，所以這次要來挑戰<strong>不使用繪圖軟體，而是用程式碼製作長輩圖！</strong>完成後，記得回傳給你家中最親愛的長輩。</p><h4>顯示圖片</h4><p>首先，把要使用的底圖加到playground（最好用png），作法：</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/%E5%A6%82%E4%BD%95%E5%9C%A8-playground-%E5%8A%A0%E5%85%A5%E5%9C%96%E7%89%87-d13e230372cb">在 playground 加入圖片，音樂等素材檔案</a></p><p>接著用程式把它叫出來。</p><pre>import UIKit</pre><pre>let flowerImage = UIImage(named: “flower.png”)</pre><pre>let flowerImageView = UIImageView(image: flowerImage)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*4TqImcruVjP_60Q_2ZezTQ.png" /></figure><h4>利用 UIView 的 property 調整元件的基本特性</h4><p>由於 label、image view 等各種 UI 元件都繼承 UIView，所以它們都具有 UIView 的 property。</p><p>可以利用frame來調整圖片大小及位置，我希望把圖片切成正方形的。</p><pre>flowerImageView.frame = CGRect(x: 0, y: 0, width: 400, height: 400)</pre><p>若想圖片維持比例不變形，可設定 property contentMode。</p><pre>flowerImageView.contentMode = .scaleAspectFit //維持比例但上下或左右留白</pre><pre>flowerImageView.contentMode = .scaleAspectFill //維持比例並填滿 frame 的框框，超出的部分被切掉。</pre><p>圖片我使用<strong>維持比例並填滿 frame</strong>的樣式。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0POPX7MYCAqI1BX0lkrhGQ.png" /></figure><h4>顯示文字的 UILabel</h4><p>接下來加入文字。</p><blockquote><strong>文字 : text</strong></blockquote><pre>let morningLabel = UILabel(frame:CGRect(x: 50, y: 50, width: 300,height: 50))</pre><pre>morningLabel.text = “早安我的朋友”</pre><blockquote><strong>文字顏色 : textColor</strong></blockquote><pre>morningLabel.textColor = UIColor(red: 1, green: 63/255, blue: 176/255, alpha: 1)</pre><blockquote><strong>文字大小 : font</strong></blockquote><pre>morningLabel.font = UIFont.systemFont(ofSize: 45)</pre><blockquote>將文字放到圖片上</blockquote><p>雖然加入了圖片及文字，但現在它們還是分開的，沒有疊在一起，所以要寫程式將背景圖上面加入文字Label。</p><pre>flowerImageView.addSubview(morningLabel)</pre><p>參考資料：</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/%E5%88%A9%E7%94%A8-uiview-%E7%9A%84-addsubview-%E5%B0%87-view-%E5%8A%A0%E5%88%B0%E5%8F%A6%E4%B8%80%E5%80%8B-view-%E4%B8%8A-8b20c91d5b7c">利用 UIView 的 addSubview 將 view 加到另一個 view 上</a></p><p>順著這個步驟多放幾組文字上去。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*87-ZIqiHdudKwGyiuuVjsQ.png" /></figure><h4>控制邊框寬度，邊框顏色， 圓角的 CALayer</h4><p>長輩圖怎麼只能有圖跟字呢？會不會太單調，必須來點華麗的！</p><blockquote><strong>邊框寬度 : borderWidth</strong></blockquote><pre>flowerImageView.layer.borderWidth = 10</pre><blockquote><strong>邊框顏色 : borderColor</strong></blockquote><pre>flowerImageView.layer.borderColor = CGColor(red: 0, green: 0, blue: 0, alpha: 1)</pre><blockquote><strong>圓角 : cornerRadius</strong></blockquote><pre>flowerImageView.layer.cornerRadius = 50</pre><pre>flowerImageView.clipsToBounds = true</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4o9woHy6xN--LYpb5ymChw.png" /></figure><p>做到這邊，越來越有感覺了XD</p><h4>加入 emoji</h4><p>最後再放幾個表情符號，就更完美了。</p><blockquote><strong>文字 : text</strong></blockquote><p>想做多顆星星，可以用var（變數）去指定。</p><pre>var starLabel = UILabel(frame: CGRect(x:20,y:20,width:55,height:55))</pre><pre>starLabel.text = “⭐️”</pre><pre>starLabel.font = UIFont.systemFont(ofSize: 55)</pre><blockquote>旋轉</blockquote><p>從 UIView 的 property transform 設定，.pi 代表 180 度， 45 度則是 .pi / 180 * 45。</p><pre>starLabel.transform = CGAffineTransform(rotationAngle: .pi / 180 * 45)</pre><h4>完成長輩圖</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*7uZTMwkYNkn19xf893lhRA.png" /></figure><p>完成了！沒想到有一天我也可以用程式製作長輩圖，喜歡的朋友們趕快下載下來，傳給你最親愛的長輩吧！</p><p>程式碼：</p><pre>import UIKit</pre><pre>//底圖</pre><pre>let flowerImage = UIImage(named: “flower.png”)</pre><pre>let flowerImageView = UIImageView(image: flowerImage)</pre><pre>flowerImageView.frame = CGRect(x: 0, y: 0, width: 400, height: 400)</pre><pre>flowerImageView.contentMode = .scaleAspectFill</pre><pre>//文字</pre><pre>let morningLabel = UILabel(frame:CGRect(x: 50, y: 50, width: 300,height: 50))</pre><pre>morningLabel.text = “早安我的朋友”</pre><pre>morningLabel.textColor = UIColor(red: 1, green: 63/255, blue: 176/255, alpha: 1)</pre><pre>morningLabel.font = UIFont.systemFont(ofSize: 45)</pre><pre>flowerImageView.addSubview(morningLabel)</pre><pre>let messageLabel = UILabel(frame:CGRect(x: 20, y: 150, width: 400,height: 100))</pre><pre>messageLabel.text = “記得笑口常開”</pre><pre>messageLabel.textColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1)</pre><pre>messageLabel.font = UIFont.systemFont(ofSize: 60)</pre><pre>flowerImageView.addSubview(messageLabel)</pre><pre>let shareLabel = UILabel(frame:CGRect(x: 150, y: 250, width: 400,height: 100))</pre><pre>shareLabel.text = “認同請分享”</pre><pre>shareLabel.textColor = UIColor(red: 0, green: 0, blue: 1, alpha: 1)</pre><pre>shareLabel.font = UIFont.systemFont(ofSize: 50)</pre><pre>flowerImageView.addSubview(shareLabel)</pre><pre>//圓角與邊框</pre><pre>flowerImageView.layer.borderWidth = 10</pre><pre>flowerImageView.layer.borderColor = CGColor(red: 1, green: 222/255, blue: 0, alpha: 1)</pre><pre>flowerImageView.layer.cornerRadius = 50</pre><pre>flowerImageView.clipsToBounds = true</pre><pre>//emoji</pre><pre>var starLabel = UILabel(frame: CGRect(x:20,y:20,width:55,height:55))</pre><pre>starLabel.text = “⭐️”</pre><pre>starLabel.font = UIFont.systemFont(ofSize: 55)</pre><pre>starLabel.transform = CGAffineTransform(rotationAngle: .pi / 180 * 45)</pre><pre>flowerImageView.addSubview(starLabel)</pre><pre>starLabel = UILabel(frame: CGRect(x:330,y:20,width:55,height:55))</pre><pre>starLabel.text = “⭐️”</pre><pre>starLabel.font = UIFont.systemFont(ofSize: 55)</pre><pre>starLabel.transform = CGAffineTransform(rotationAngle: .pi / 180 * 90)</pre><pre>flowerImageView.addSubview(starLabel)</pre><pre>starLabel = UILabel(frame: CGRect(x:330,y:330,width:55,height:55))</pre><pre>starLabel.text = “⭐️”</pre><pre>starLabel.font = UIFont.systemFont(ofSize: 55)</pre><pre>starLabel.transform = CGAffineTransform(rotationAngle: .pi / 180 * 180)</pre><pre>flowerImageView.addSubview(starLabel)</pre><pre>starLabel = UILabel(frame: CGRect(x:20,y:330,width:55,height:55))</pre><pre>starLabel.text = “⭐️”</pre><pre>starLabel.font = UIFont.systemFont(ofSize: 55)</pre><pre>starLabel.transform = CGAffineTransform(rotationAngle: .pi / 180 * 165)</pre><pre>flowerImageView.addSubview(starLabel)</pre><pre>var smileLabel = UILabel(frame: CGRect(x:100,y:100,width:400,height:55))</pre><pre>smileLabel.text = “😄😄😄😄😄😄”</pre><pre>smileLabel.font = UIFont.systemFont(ofSize: 45)</pre><pre>flowerImageView.addSubview(smileLabel)</pre><pre>smileLabel = UILabel(frame: CGRect(x:0,y:230,width:400,height:55))</pre><pre>smileLabel.text = “😚😚😚😚😚😚”</pre><pre>smileLabel.font = UIFont.systemFont(ofSize: 45)</pre><pre>flowerImageView.addSubview(smileLabel)</pre><p>參考資料：</p><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><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dd22332330e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/8%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%E9%95%B7%E8%BC%A9%E5%9C%96-2dd22332330e">＃8使用圖片，文字，emoji，邊框 &amp; 圓角製作長輩圖</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[＃7用 Swift 打造跳舞機器人 BoogieBot]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/7%E7%94%A8-swift-%E6%89%93%E9%80%A0%E8%B7%B3%E8%88%9E%E6%A9%9F%E5%99%A8%E4%BA%BA-boogiebot-6ae51544c696?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ae51544c696</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Sun, 01 Aug 2021 12:12:12 GMT</pubDate>
            <atom:updated>2021-08-01T15:30:09.816Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x7WOZGTBRR5NeVgM458EgQ.jpeg" /></figure><p>從上週開始，我們終於開始進入程式課程了，在寫自己原生的程式前，第一步是學習如何使用別人（蘋果）寫的程式，而這次要來練習用程式寫出跳舞機器人。</p><h4>下載student materilas</h4><p>首先，下載電子書 Develop in Swift Explorations ，點選以下頁面的 Download student materilas 下載範例檔案(第 11 頁)。</p><p><a href="https://books.apple.com/tw/book/develop-in-swift-explorations/id1556366287">‎Develop in Swift Explorations</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tvZoqwyXmbKNVuTy.jpeg" /></figure><p>接著打開BoogieBot.playground 中的 2-Algorithms &gt; 2-Play with Programs &gt; E-BoogieBot 。</p><p>開啟檔案後，會看到機器人，接著按下Next切換到10頁，準備寫程式。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlNP7teQ0R3PByWi8cy46w.jpeg" /></figure><h4>寫程式</h4><p>BoogieBot 的 API 提供以下 function，可以用來操控機器人的動作 :</p><pre>基本的指令：</pre><pre>startBot() //啟動機器人<br>startRecording() //開始錄製<br>setBotTitle(&quot;動感之舞&quot;) //機器人上方標題的名稱<br>setBotSubtitle(&quot;第一跳&quot;) //機器人下方的副標題名稱<br>fabulize() // 機器人變色<br>defabulize() //機器人變回預設顏色</pre><pre>//跳的動作<br>jumpUp() //機器人往上跳<br>jumpDown() //機器人往下跳</pre><pre>//腰的動作<br>shakeItLeft() //向左扭腰<br>shakeItRight() //向右扭腰<br>shakeItCenter() //腰回中心</pre><pre>//腿的動作<br>leftLegUp() //抬起左腿<br>leftLegDown() //放下左腿<br>rightLegUp() //抬起右腿<br>rightLegDown() //放下右腿</pre><pre>//手的動作<br>leftArmUp() //舉起左手臂<br>leftArmDown() //放下左手臂<br>rightArmUp() //舉起右手臂<br>rightArmDown() //放下右手臂</pre><p>再來找首歌，替機器人編舞。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JXKQOIiD2tkglG6zP2LH_w.jpeg" /></figure><h4>成品完成</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FOro9IuCD3qM&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOro9IuCD3qM&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FOro9IuCD3qM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/43931bcd1ef95f489ab1e7587d8c0c29/href">https://medium.com/media/43931bcd1ef95f489ab1e7587d8c0c29/href</a></iframe><p>ヾ(´︶`*)ﾉ♬</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ae51544c696" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/7%E7%94%A8-swift-%E6%89%93%E9%80%A0%E8%B7%B3%E8%88%9E%E6%A9%9F%E5%99%A8%E4%BA%BA-boogiebot-6ae51544c696">＃7用 Swift 打造跳舞機器人 BoogieBot</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[#6實作Storyboard 音樂串流 App]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/6%E5%AF%A6%E4%BD%9Cstoryboard-%E9%9F%B3%E6%A8%82%E4%B8%B2%E6%B5%81-app-f114b64ec92e?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/f114b64ec92e</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Thu, 22 Jul 2021 11:39:57 GMT</pubDate>
            <atom:updated>2021-07-27T16:55:53.749Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*srBR0r7uCiaIPWSTaUhEUg.jpeg" /></figure><p>畫完設計稿後，這次要來練習不寫任何程式，利用Storyboard的 tab bar controller，navigation controller，table view controller &amp; static cell 製作出音樂串流的 App。</p><p>先承認…之前我一直以為不用寫程式，應該很快就能做好了吧！</p><p>於是在畫設計稿時，一不小心就畫得太開心、太複雜了，原本預計一個晚上搞定，結果最後我整整花了<strong>4個晚上</strong>！！做完後我真的想給所有的工程師一個Respect，今天終於體會到了自己的設計稿有多難刻QQ</p><p>還好在實作的過程中，發現Xcode的快捷鍵很多都跟Figma一樣，例如檢查間距、複製元件等等，省下了很多操作上的時間。</p><h4>調整架構</h4><p>在製作畫面之前，我進到Xcode的第一件事情是先調整App的結構，利用Navigation、Tab Bar Controller、Navigation Controller及View Controller去建構我所需要的頁面。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S3xM1zt6Q3Wgf9d-2rZXpA.png" /><figcaption>App結構</figcaption></figure><p>接著我調整了Tab Bar的顏色及icon，這裡記得要點選Navigation Controller才能調整該icon及名稱。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XcFl1gS1X1wFrKAnNCWhww.png" /><figcaption>Navigation Controller</figcaption></figure><h4>運用元件</h4><p>在製作畫面時，我用到了幾個元件：</p><blockquote>水平捲動</blockquote><p>第一個畫面中，專輯列表的區塊我用Scroll View製作水平滾動的效果。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xyQpCc5IkLDvPiEgdh6Jg.jpeg" /><figcaption>專輯列表</figcaption></figure><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><blockquote>圖片點選</blockquote><p>接著加上Button，讓專輯圖片可以被點擊。</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/%E5%88%A9%E7%94%A8-segue-%E5%AF%A6%E7%8F%BE%E5%9C%96%E7%89%87%E9%BB%9E%E9%81%B8%E7%9A%84%E6%8F%9B%E9%A0%81%E5%8A%9F%E8%83%BD-84f6991d74d4">利用 segue 實現圖片點選的換頁功能</a></p><blockquote>Container View</blockquote><p>第二個畫面中，我原本預計利用Table View-Static Cell製作歌曲的列表，但怎麼試都不成功，詢問老師後，才發現原來不是 Table View Controller不能使用Static Cell，於是在老師的建議下，改用Container View的方式。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0v0-p8MPBTMamUf8RoYGOQ.jpeg" /><figcaption>歌曲列表</figcaption></figure><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/static-cells-%E5%8F%AA%E8%83%BD%E6%90%AD%E9%85%8D-table-view-controller-dc0aa4bf3b4">Static Cells 只能搭配 Table View Controller</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/%E8%A8%AD%E5%AE%9A%E8%A1%A8%E6%A0%BC%E7%9A%84%E8%83%8C%E6%99%AF%E5%9C%96%E7%89%87-45508aa6f630">設定表格的背景圖片</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFzr0-BpvKS23UB6ijhdFQ.jpeg" /><figcaption>歌曲列表</figcaption></figure><p>Table View Cell有個小缺點，就是它預設點選時會出現顏色（什麼老派作法？），可以在Selection設定＞None，讓點選時不要出現顏色。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CvvBDKl8Muzpyxu2p6bnQw.jpeg" /><figcaption>Selection＞None</figcaption></figure><blockquote>Search Bar</blockquote><p>在搜尋頁面新增Search Bar，我目前還不會修改樣式，於是先使用預設的。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9siA2sETeWV60XjQh7wFg.jpeg" /><figcaption>Search Bar</figcaption></figure><blockquote>Button、View、Label</blockquote><p>在其他頁面的區塊中，我都大量使用了Button、View、Label三種元件（雖然不知道這樣做程式最後會不會長得很醜），如利用Button+View製作Tab，這時候的Tab還沒辦法做切換的動作，必須等未來學習寫程式後才能切換。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k9pu__tmVNRWputHkseF-w.jpeg" /><figcaption>Tab</figcaption></figure><blockquote><em>Progress View(進度條）</em></blockquote><p>利用Progress View製作歌曲播放時的進度。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fqFxgq4b7tpesPqFKqEQug.jpeg" /><figcaption>Progress View</figcaption></figure><blockquote>Navigation Bar樣式</blockquote><p>在製作過程中，我一直很想修改&lt; Back 的樣式，讓它跟設計稿一致，但變動Navigation Bar的樣式需要寫程式，我還沒有學到，試了幾次都還是失敗，我決定果斷放棄！等到之後學了程式再回來修改。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nnr5MvfZOesn_ilW8kTn8Q.png" /><figcaption>&lt; Back</figcaption></figure><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%BE%9E%E7%A8%8B%E5%BC%8F%E8%A8%AD%E5%AE%9A-uikit-navigation-bar-tab-bar-%E7%9A%84%E6%A8%A3%E5%BC%8F-c9728e37e1e7">從 Interface Builder &amp; 程式設定 UIKit navigation bar &amp; tab bar 的樣式</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*9lszcENLbBeUbwL9.JPG" /></figure><blockquote>開頭畫面</blockquote><p>LaunchScreen可以設定開頭畫面，它會在開啟App時顯示，但只會出現1 ～2秒鐘。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yf1vaJOjz80d7_mtWuEokg.jpeg" /><figcaption>開頭畫面</figcaption></figure><blockquote>設定icon</blockquote><p>製作各種場合必須要出現的App icon。</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/%E5%BE%9E-app-icon-generator-%E7%94%A2%E7%94%9F-ios-app-icon-402b0d2cd2e6">從  App Icon Generator 產生 iOS App Icon</a></p><p>在把icon貼進Xcode的過程中，我一直不小心把原本的資料夾刪掉，且新的一直沒有覆蓋成功，所以想預覽模擬器時就顯示錯誤訊息。</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/app-icon-%E4%B8%8D%E8%A6%8B%E7%9A%84%E7%B4%85%E8%89%B2%E9%8C%AF%E8%AA%A4-545fe92fd2f0">App Icon 不見的紅色錯誤</a></p><p>試著貼上好幾次一直不成功，最後終於發現原來是新icon放錯資料夾了QQ</p><p>（記得要打開icon資料夾，裡面的AppIcon.appiconset才是正港的）</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RC6aViWlYN4c9RUC1_w2yg.jpeg" /><figcaption>AppIcon.appiconset</figcaption></figure><blockquote>打上App名稱</blockquote><p>專案資料夾中＞Display Name中可以打上欲顯示的App名稱。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cnhZaD6TEF8Gcppog4zGSw.jpeg" /></figure><h4>最終完成品</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*LaKI0KF6M03ogrUJrueS0A.gif" /></figure><p>最後我的App歷經四個艱辛的夜晚終於完成了！真的學到了很多，雖然辛苦但還好最後做出來跟設計圖相差不遠（不然我會氣死），只有Back跟Search Bar的地方不太一樣，因為需要程式，所以等日後學程式之後再做調整吧！</p><p>Github連結：</p><p><a href="https://github.com/jesshsu23/music-app">GitHub - jesshsu23/music-app</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f114b64ec92e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/6%E5%AF%A6%E4%BD%9Cstoryboard-%E9%9F%B3%E6%A8%82%E4%B8%B2%E6%B5%81-app-f114b64ec92e">#6實作Storyboard 音樂串流 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[＃5從 Figma實作 App 畫面]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/5%E5%BE%9E-figma%E5%AF%A6%E4%BD%9C-app-%E7%95%AB%E9%9D%A2-2a5102ea36a?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a5102ea36a</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Sun, 18 Jul 2021 17:08:58 GMT</pubDate>
            <atom:updated>2021-07-23T07:56:01.296Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*srBR0r7uCiaIPWSTaUhEUg.jpeg" /><figcaption>音樂串流平台App</figcaption></figure><p>練習完許多常用的UI元件後，預計下一個單元就會開始利用Storyboard練習做出電子書App了！在選擇主題時想了很久，後來想到平常其實最常用的軟體應該就是音樂串流平台了，每天上班都一定會打開並收聽各種音樂及Podcase，所以最後我就決定以模仿Spotify做音樂的主題。</p><p>在進Xcode以前，我習慣先在Figma找喜歡的素材，並設計一些頁面，這次預計製作首頁、搜尋頁及我的音樂頁面。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jvwUyaKi8XBNl3sGxIKDuA.png" /><figcaption>音樂串流平台頁面</figcaption></figure><p>最後將這些頁面製作成簡單的Prototype，這樣子之後在Xcode製作時，我能更清楚流程，以及應該要使用哪些功能。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*5S-dnq019J5Lq5gzlKTQGg.gif" /><figcaption>Prototype</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a5102ea36a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/5%E5%BE%9E-figma%E5%AF%A6%E4%BD%9C-app-%E7%95%AB%E9%9D%A2-2a5102ea36a">＃5從 Figma實作 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[#4如何錄製App Gif（附上GitHub）]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/4%E5%A6%82%E4%BD%95%E9%8C%84%E8%A3%BDapp-gif-%E9%99%84%E4%B8%8Agithub-2e679fcea0a3?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e679fcea0a3</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Mon, 12 Jul 2021 14:29:08 GMT</pubDate>
            <atom:updated>2021-08-09T14:11:03.732Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuCUlaAYpc5HZGubX-JSGQ.jpeg" /></figure><p>當我們製作好一個App，還沒有上線卻需要向別人展示，這時候就需要利用影片去呈現畫面上的效果，那麼要怎麼在Xcode中錄製畫面操作的Gif檔呢？</p><p>步驟其實非常簡單：</p><ol><li>首先在Xcode中按下三角形播放鍵叫出Simulator模擬器。</li><li>到File中選擇Record Screen/或在模擬器上方的 bar按下option，原本螢幕照相會變成螢幕錄製。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*Dm666ed8X1GYITSq047RgQ.jpeg" /></figure><p>3. 此時模擬器上方的 bar 將出現錄製按鈕，表示開始錄製，再按一下即錄製完畢。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*GL68osQnk755AfKwDTYXmA.jpeg" /></figure><p>4. 錄製結束後，右下方會出現影片預覽，從預覽畫面中按右鍵 &gt;點選Save as Animated GIF，此時Gif檔會被自動儲存在桌面。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*DnUUhAHhzAfU6wZ1GpsaeA.jpeg" /></figure><p>此時螢幕錄製的Gif檔就完成拉～</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*MbOYHZUOwt0kFfANCl2Cag.gif" /></figure><p>附上我的GitHub :</p><p><a href="https://github.com/jesshsu23">jesshsu23 - Overview</a></p><p>參考資料：</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/%E7%86%9F%E6%82%89-app-%E5%BD%B1%E7%89%87%E9%8C%84%E8%A3%BD-github-medium-%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84ios-app-%E4%BD%9C%E6%A5%AD-646d009f43fc">熟悉 App gif 錄製，GitHub，Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e679fcea0a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/4%E5%A6%82%E4%BD%95%E9%8C%84%E8%A3%BDapp-gif-%E9%99%84%E4%B8%8Agithub-2e679fcea0a3">#4如何錄製App Gif（附上GitHub）</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[#3熟悉Xcode 常用 UI 元件]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/3%E7%86%9F%E6%82%89xcode-%E5%B8%B8%E7%94%A8-ui-%E5%85%83%E4%BB%B6-33c854340f3?source=rss-7c5708eec05------2</link>
            <guid isPermaLink="false">https://medium.com/p/33c854340f3</guid>
            <dc:creator><![CDATA[Jess Hsu]]></dc:creator>
            <pubDate>Mon, 12 Jul 2021 13:04:07 GMT</pubDate>
            <atom:updated>2021-08-09T14:11:32.335Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U4_3VhrLOaP7Uw4yHZ51Xw.jpeg" /></figure><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">彼得潘</a>說要熟悉的元件：Segmented Control，Slider，Switch，Activity Indicator View，Progress View，Page Control，Date Picker，Visual Effect View with Blur。</p><p>到Project中＞選取Main＞打開View Controller＞點選＋，就能不需要任何程式，叫出許多UI元件。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oBLrsUl__bhhqN1QgWhJ3g.jpeg" /></figure><blockquote><strong>Segmented Control (分段控制)</strong></blockquote><p>Segmented Controlg是個像Tab的元件，可以用來製作切換分頁的效果。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NBk2cf-w4PkxgsXqYE8SIg.jpeg" /></figure><p>叫出Segmented Controlg後，試了幾個操作項目：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*irmCjh17RxM3KJyDKBYFIw.jpeg" /></figure><ul><li>Segments : 設定分頁的數量，預設為2，不可以小於2。</li><li>Segment : 修改每個分頁的Title/Image等資訊 。</li><li>Title : 分頁上的標題文字。</li><li>Image : 分頁上的小圖示，與文字只能二擇一。</li><li>Selected Tint：設定指定分頁的按鈕顏色。</li><li>Background : 設定Segmented Controlg的底色。</li></ul><blockquote>Slider<strong> (滑桿)</strong></blockquote><p>用來操作滑動設定值的元件，可以透過拉桿來控制不同的數值。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BiJkvJkgvC_s2UQe8PG3Ww.jpeg" /></figure><ul><li>Value : 目前滑桿上的值。</li><li>Minimum : 設定最小值。</li><li>Maximum : 設定最大值。</li><li>Min Track : 靠近最小值滑桿上的顏色。</li><li>Max Track : 靠近最大值滑桿上的顏色。</li><li>Thumb Tint : 設定滑桿上面圓點按鈕的顏色。</li></ul><blockquote>Switch<strong> (開關)</strong></blockquote><p>可以利用開關元件打開/關閉某種狀態，例如選擇是否打開夜間模式、隱私權設定。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVKnMFSkdJ080cAMU5W34Q.jpeg" /></figure><ul><li>State : 設定開關預設的狀態。</li><li>On Tint : 開關的底色。</li><li>Thumb Tint : 開關圓點按鈕的顏色。</li></ul><blockquote>Activity Indicator View(Loading狀態)</blockquote><p>使用Loading狀態可以表示頁面正在載入，例如頁面整理中、資料搜尋中。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVFGYpHoa8HG40ol25bX-A.jpeg" /></figure><ul><li>Style : 設定大小及樣式。</li><li>Color : 設定顏色。</li><li>Animating : 打勾後再預覽時就會有動畫效果。</li></ul><blockquote>Progress View(進度條）</blockquote><p>顯示進度狀況的進度條，例如圖片下載進度。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6sdCmplDLl5ogMSvaH2cmw.jpeg" /></figure><ul><li>Style : 可切換進度條的兩種樣式。</li><li>Progress : 當前進度值，範圍為 0–1 之間。</li><li>Progress Tint : 調整當前進度條的顏色。</li><li>Track Tint : 調整進度條的顏色。</li></ul><blockquote>Page Control<strong><em> (頁面控制)</em></strong></blockquote><p>利用圓點顯示分頁數量及目前所在分頁，例如圖片輪播。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JuXz0NdVKSJjURzFl8QJnQ.jpeg" /></figure><ul><li># of Pages : 調整總頁數，元件寬度要夠長才能顯示所有數目。</li><li>Current : 目前所在頁數，0 是第一頁。</li><li>Tint Color : 顯示所有頁面的顏色。</li><li>Current Page : 目前所在頁面的顏色。</li></ul><blockquote>Date Picker<strong>（選取日期時間）</strong></blockquote><p>選擇時間日期的元件。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nXzbhpSYK5aACxx3KN_OpA.jpeg" /></figure><ul><li>Preferred Style : 選擇日曆的樣式。</li><li>Mode : 日曆顯示的項目，可選擇Time（時間）、Date（日期）、Date and Time（時間及日期）、Count down timer（倒數計時），4種。</li><li>Locale : 所在的地區。</li><li>Interval : 選擇時間的間隔。</li><li>Date : Custom(自訂日期)/Current Date(當前日期）。</li><li>Minimum Date : 設定最早的時間。</li><li>Maximum Date : 設定最晚的時間。</li></ul><blockquote>Visual Effect View with Blur (毛玻璃效果)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7ruJxsuc9SMTlIva2SCHA.jpeg" /></figure><ul><li>Blur Style : 可以選擇毛玻璃的效果樣式。</li></ul><p>以上就是這次練習的UI元件，希望未來加上程式碼後，可以有更加完整的作品呈現！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33c854340f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/3%E7%86%9F%E6%82%89xcode-%E5%B8%B8%E7%94%A8-ui-%E5%85%83%E4%BB%B6-33c854340f3">#3熟悉Xcode 常用 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>