From b494635e951afe66a2f291868d1a44148a7c5e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E7=8E=AE?= Date: Fri, 27 Apr 2018 18:55:22 +0800 Subject: [PATCH] Update: readme --- .../DWBarHUD/BarHUDViewController.swift | 4 +- DWBarHUDDemo/DWBarHUD/DWBarHUD.swift | 38 ++++++------- .../DWBarHUDDemo/ViewController.swift | 1 + README.md | 53 +++++++++++++++++++ 4 files changed, 72 insertions(+), 24 deletions(-) diff --git a/DWBarHUDDemo/DWBarHUD/BarHUDViewController.swift b/DWBarHUDDemo/DWBarHUD/BarHUDViewController.swift index 395ee8c..898fb6c 100644 --- a/DWBarHUDDemo/DWBarHUD/BarHUDViewController.swift +++ b/DWBarHUDDemo/DWBarHUD/BarHUDViewController.swift @@ -127,12 +127,12 @@ extension BarHUDViewController { } HUDView.backgroundColor = HUDConfig.barSuccessColor case .fail: - if let icon = HUDConfig.barFailIcon { + if let icon = HUDConfig.barFailedIcon { iconImageView.image = icon } else { iconImageView.isHidden = true } - HUDView.backgroundColor = HUDConfig.barFailColor + HUDView.backgroundColor = HUDConfig.barFailedColor case .warning: if let icon = HUDConfig.barWarningIcon { iconImageView.image = icon diff --git a/DWBarHUDDemo/DWBarHUD/DWBarHUD.swift b/DWBarHUDDemo/DWBarHUD/DWBarHUD.swift index 21341d6..9dc1b05 100644 --- a/DWBarHUDDemo/DWBarHUD/DWBarHUD.swift +++ b/DWBarHUDDemo/DWBarHUD/DWBarHUD.swift @@ -8,7 +8,7 @@ import UIKit -enum DWBarAnimationType { +public enum DWBarAnimationType { case `default` case spring case fade @@ -52,41 +52,35 @@ public struct HUDConfig { // MARK: - Properties // MARK: - DWBarProtocol /// 成功状态Icon - var barSuccessIcon: UIImage? = DWHUDAssets.successIcon + public var barSuccessIcon: UIImage? = DWHUDAssets.successIcon /// 警告状态Icon - var barWarningIcon: UIImage? = DWHUDAssets.warningIcon + public var barWarningIcon: UIImage? = DWHUDAssets.warningIcon /// 失败状态Icon - var barFailIcon: UIImage? = DWHUDAssets.failIcon + public var barFailedIcon: UIImage? = DWHUDAssets.failIcon /// 普通状态Icon - var barDefaultIcon: UIImage? = DWHUDAssets.defaultIcon + public var barDefaultIcon: UIImage? = DWHUDAssets.defaultIcon /// HUD高度 - var barHeight: CGFloat = 70 + public var barHeight: CGFloat = 70 /// 成功状态背景颜色 - var barSuccessColor: UIColor = UIColor(red: 65/255.0, green: 190/255.0, blue: 152/255.0, alpha: 1) + public var barSuccessColor: UIColor = UIColor(red: 65/255.0, green: 190/255.0, blue: 152/255.0, alpha: 1) /// 失败状态背景颜色 - var barFailColor: UIColor = UIColor(red: 253/255.0, green: 141/255.0, blue: 163/255.0, alpha: 1) + public var barFailedColor: UIColor = UIColor(red: 253/255.0, green: 141/255.0, blue: 163/255.0, alpha: 1) /// 警告状态背景颜色 - var barWarningColor: UIColor = UIColor(red: 255/255.0, green: 204/255.0, blue: 30/255.0, alpha: 1) + public var barWarningColor: UIColor = UIColor(red: 255/255.0, green: 204/255.0, blue: 30/255.0, alpha: 1) /// 普通状态背景颜色 - var barDefaultColor: UIColor = .lightGray + public var barDefaultColor: UIColor = .lightGray /// 提示信息字体 - var barMessageFont: UIFont = UIFont.systemFont(ofSize: 15, weight: .semibold) + public var barMessageFont: UIFont = UIFont.systemFont(ofSize: 15, weight: .semibold) /// 提示信息字体颜色 - var barMessageFontColor: UIColor = .white - /// 按钮标题 - var barActionButtonTitle: String? = nil - /// 按钮标题颜色 - var barActionButtonTitleColor: UIColor = .white - /// 按钮标题字体 - var barActionButtonFont: UIFont = UIFont.systemFont(ofSize: 14) + public var barMessageFontColor: UIColor = .white /// 是否显示icon - var showIcon: Bool = true + public var showIcon: Bool = true /// HUD显示时间 - var displayDuration: TimeInterval = 2.0 + public var displayDuration: TimeInterval = 2.0 /// HUD显示动画时长 - var animationDuration: TimeInterval = 0.3 + public var animationDuration: TimeInterval = 0.3 /// HUD显示动画类型 - var animationType: DWBarAnimationType = .default + public var animationType: DWBarAnimationType = .default fileprivate func showHUD(type: BarHUDType = .default, message: String) { let vc = BarHUDViewController() diff --git a/DWBarHUDDemo/DWBarHUDDemo/ViewController.swift b/DWBarHUDDemo/DWBarHUDDemo/ViewController.swift index b5c6413..41f3545 100644 --- a/DWBarHUDDemo/DWBarHUDDemo/ViewController.swift +++ b/DWBarHUDDemo/DWBarHUDDemo/ViewController.swift @@ -13,6 +13,7 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + DWBarHUD.sharedHUD.config.animationDuration = 1.0 // Do any additional setup after loading the view, typically from a nib. } diff --git a/README.md b/README.md index e0e63e6..4111394 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,56 @@ # DWBarHUD +![default-default](https://github.com/Dywane/DWBarHUD/raw/master/GIF/default-default.gif) + +DWBarHUD is a **Swfit** based top bar HUD for iOS 9 and above, support iPhoneX. + +## Features +* Fully customizable. +* Show on top of view controlles. +* Four styles suit all needs. +* Present/Dismiss animation. + +![failed-fade](https://github.com/Dywane/DWBarHUD/raw/master/GIF/fail-fade.gif) + +![success-default](https://github.com/Dywane/DWBarHUD/raw/master/GIF/success-default.gif) + +![warning-spring](https://github.com/Dywane/DWBarHUD/raw/master/GIF/warning-spring.gif) + +## Usage +In any UIViewController, you need to import the module first + +```swift +import DWBarHUD +``` + +Then you can show an HUD and automatic disappear like this: + +```swift +DWBarHUD.showHUD(message: "This is a message", type: .success) +``` + +## Customization +There are many properties you can customize. + +* `DWBarHUD.sharedHUD.config.animationDuration` defines how long to present the HUD animation +* `DWBarHUD.sharedHUD.config.displayDuration` defines how long the HUD show +* `DWBarHUD.sharedHUD.config.barHeight` defines the height of the HUD +* `DWBarHUD.sharedHUD.config.animationType` defines the HUD animation type +* `DWBarHUD.sharedHUD.config.barSuccessIcon` & `DWBarHUD.sharedHUD.config.barSuccessColor` this two define success type's icon and color + +more can be seen in Xcode + +## Requirements +* iOS 9.0+ +* Swift 4 +* Xcode 9 + +## Contribution +You are welcome to fork and submit pull requests or issues. + +## License +DWBarHUD is open-sourced software licensed under the MIT license. + +## Credits +DWBarHUD is owned and maintained by [Duwei](https://dywane.github.io) \ No newline at end of file