iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 16
0
Software Development

30 天上手 iOS App 開發系列 第 23

30 天上手 iOS App 開發 Day 24

在開發程式時,難免會遇到需要等待的程式碼,如下載進度,或者串接 Web Service 的服務,如果沒有一個等待的通知給使用者,會讓使用者有當機或者不好的使用經驗。「SVProgressHUD」則是一個進度顯示工具,簡單且快速。

首先在 Podfile 中加入

pod 'SVProgressHUD'

接著將套件安裝在專案中

pod install

接著在 StoryBoard 中進行以下佈局

https://ithelp.ithome.com.tw/upload/images/20180118/20107506t9WHl4QH5A.png

接著來看看每個 Action 中會呈現的效果

    @IBAction func showAction(_ sender: Any) {
        SVProgressHUD.show()
    }

https://ithelp.ithome.com.tw/upload/images/20180118/20107506LkqqklQNIj.png

    @IBAction func showWithStatus(_ sender: Any) {
        SVProgressHUD.show(withStatus: "showWithStatus")
    }

https://ithelp.ithome.com.tw/upload/images/20180118/20107506k164uLoOCa.png

    @IBAction func showWithProgress(_ sender: Any) {
        SVProgressHUD.showProgress(0.3)
    }

https://ithelp.ithome.com.tw/upload/images/20180118/20107506YcLOfymO9g.png

    @IBAction func showInfoWithStatus(_ sender: Any) {
        SVProgressHUD.showInfo(withStatus: "showInfoWithStatus")
    }

https://ithelp.ithome.com.tw/upload/images/20180118/20107506hsTFoOtjzF.png

    @IBAction func showSuccessWithStatus(_ sender: Any) {
        SVProgressHUD.showSuccess(withStatus: "showSuccessWithStatus")
    }

https://ithelp.ithome.com.tw/upload/images/20180118/20107506H0lMsZOZzB.png

    @IBAction func showErrorWithStatus(_ sender: Any) {
        SVProgressHUD.showError(withStatus: "showErrorWithStatus")
    }

https://ithelp.ithome.com.tw/upload/images/20180118/20107506CxBF02VCaf.png

    @IBAction func dismissAction(_ sender: Any) {
        SVProgressHUD.dismiss()
    }

上一篇
30 天上手 iOS App 開發 DAY 23
下一篇
30 天上手 iOS App 開發 Day 25
系列文
30 天上手 iOS App 開發28
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言