Skip to content

Commit

Permalink
Update: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Dywane committed Apr 27, 2018
1 parent e68c413 commit b494635
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 24 deletions.
4 changes: 2 additions & 2 deletions DWBarHUDDemo/DWBarHUD/BarHUDViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 16 additions & 22 deletions DWBarHUDDemo/DWBarHUD/DWBarHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

enum DWBarAnimationType {
public enum DWBarAnimationType {
case `default`
case spring
case fade
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions DWBarHUDDemo/DWBarHUDDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit b494635

Please sign in to comment.