From 9d4dc6163394efd9742afd4c97675e20df3846b4 Mon Sep 17 00:00:00 2001 From: ZhengYidong Date: Thu, 5 Jan 2017 18:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 46ab9b9..3c7af9a 100644 --- a/README.md +++ b/README.md @@ -148,24 +148,32 @@ func load(load: MBLoadable = MBLoadType.none) -> Self #### Show mask on UIViewController +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_loadable_uiviewcontroller.gif) + ``` swift request(WeatherForm()).load(load:MBLoadType.default(container: view)) ``` #### Show mask on UINavigationController +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_loadable_uinavigationcontroller.gif) + ``` swift request(WeatherForm()).load(load: MBLoadType.default(container: navigationController!.view)) ``` #### Show mask on UIButton +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_loadable_button.gif) + ``` swift request(WeatherForm()).load(load: button) ``` #### Show customized mask +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_loadable_customized.gif) + Firstly, we create a `LoadConfig` class conforms to `MBLoadable` protocol. ``` swift @@ -214,6 +222,8 @@ This is the most powful usage of the `MBLoadable` protocol. In this way you can #### Show mask on UITableView & UIScrollView +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_loadable_uiscrollview.gif) + ``` swift let load = LoadConfig(container:self.tableView, mask: MBActivityIndicator(), inset: UIEdgeInsetsMake(UIScreen.main.bounds.width - self.tableView.contentOffset.y > 0 ? UIScreen.main.bounds.width - self.tableView.contentOffset.y : 0, 0, 0, 0)) @@ -223,6 +233,8 @@ request(WeatherForm()).load(load: load) #### Show mask on UITableViewCell (PS: Still in development) +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_loadable_cell.gif) + ``` swift override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView .deselectRow(at: indexPath, animated: false) @@ -241,6 +253,8 @@ func progress(progress: MBProgressable) -> Self And then we can use it as followed: +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_progressable.gif) + ``` swift download(ImageDownloadForm()).progress(progress: progress) ``` @@ -255,6 +269,8 @@ func warn(error: T, warn: MBWarnable = MBMessageType.none, c And then we can use it as followed: +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_warnable.gif) + ``` swift request(WeatherForm()).warn(error: WeatherError(), warn: MBMessageType.alertController(title: "Warning", message: "Network unavailable", actions: [UIAlertAction(title: "Ok", style: UIAlertActionStyle.cancel, handler: nil)], container: self)) ``` @@ -270,6 +286,8 @@ func inform(error: T, inform: MBInformable = MBMessageType.n And then we can use it as followed: +![](https://github.com/mmoaay/MBNetwork/blob/master/Demo/mbnetwork_informable.gif) + ``` swift request(WeatherForm()).inform(error: WeatherInformError(), inform: MBMessageType.alertController(title: "Notice", message: "Load successfully", actions: [UIAlertAction(title: "Ok", style: UIAlertActionStyle.cancel, handler: nil)], container: self)) ```