#21 解放 iOS SDK 的強大魔法,生成各式物件,並設定屬性及呼叫函數

利用各式 Kit 協助開發

核心練習:

  • 地圖: MapKit,MKMapView,MKCoordinateRegion
  • 播音樂: AVFoundation,URL,AVPlayer
  • 播影片: AVKit,AVPlayerViewController
  • 網頁: SafariServices,SFSafariViewController
  • 時間: Foundation,Date,DateFormatter,Calendar,DateComponents,Void
  • App 講話: AVFoundation,AVSpeechSynthesizer,AVSpeechUtterance,AVSpeechSynthesisVoice
  • playground: PlaygroundSupport,PlaygroundPage,liveView,type property
  1. 用 AVPlayer 播放音樂:AV Foundation

記得要查詢播放網址可以從彼得潘的這篇看:

2. 用 AVPlayerViewController 播影片

再度感謝大神彼得潘:這篇有解釋如何使用 Live View 來操作顯示 Controller或是 View:

3. 利用 SFSafariViewController 顯示網頁

打這段的時候不知道是不是 Xcode 出現 Bug,提示不斷消失,但最後是可以在 liveView 中看見成果的!

4. 顯示地圖

5. 列印時間

addTimeInterval 是用來計算距離現在幾秒鐘以後時間的函數~

更改時間格式並變為字串:

時間格式整理表參考:

存取現在的時間資料:

4. 用 AVSpeechSynthesizer 講話

可事後使用 .voice .rate .pitchMultiplier 來調整「要說的話」~

參考彼得潘這篇大補帖:(詳細整理)

學習完 iOS SDK 以後是不是覺得很充實呢?

--

--