HUDMakerKit 0.2.4

HUDMakerKit 0.2.4

Atsuya Sato 维护。




  • 作者:
  • Atsuya Sato

Header

Build Status Swift Pods Version Platforms Carthage Compatible GitHub license

HUDMakerKit

HUDMakerKit 是用 Swift 编写的自定义抬头显示机🐧.
HUDMakerKit 有 ProcessingKit 引擎。您可以使用 Processing 绘图函数开发自定义抬头显示。

示例

HUD 代码
SimpleHUD SimpleHUD_Code
AnimateHUD AnimateHUD Code
PeriodicallyHUD PeriodicallyHUD Code

要求

  • Swift 4.0 或更高版本
  • iOS 10.0 或更高版本

使用方法

  1. 创建继承自 HUDMaker 的自定义类
class SampleHUD: HUDMaker {
    func draw(frameCount: Int) {
     // the draw() function continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called.
    }
}
  1. draw() 函数中实现 HUD 动画
class SampleHUD: HUDMaker {
    func draw(frameCount: Int) {
        // MARK: Examples
        fill(255, 0, 0) // Sets the color used to fill shapes
        ellipse(50, 50, 100, 100) // Draws an ellipse (oval) to the screen
    }
}
  1. 创建 CustomHUD 实例并将其设置为 HUDRunner
let customHUD = SampleHUD(frame: CGRect(x: 0, y: 0, width: 150, height: 150)) // Create a new instance
customHUD.backgroundColor = UIColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 0.3)
customHUD.layer.cornerRadius = 10

HUDRunner.shared.customHUD = customHUD // Set a customHUD
HUDRunner.shared.show() // Show HUD

什么是 Processing

  • Processing 是一个灵活的软件素描本,并且在视觉艺术环境中学习如何编码的语言。
  • 它提供具有简单语法的绘图函数
  • 参考资料

在Processing中绘制椭圆

oval

// Draws an ellipse (oval) to the screen
// ellipse(center.x, center.y, width, height) 
ellipse(100, 100, 100, 100);

填充椭圆

oval_fill

// Sets the color used to fill shapes
// fill(R, G, B)

fill(255, 0, 0);
ellipse(100, 100, 100, 100);

设置描边颜色

oval_stroke

// Sets the color used to draw lines and borders around shapes
// stroke(R, G, B)

// Sets the width of the stroke used for lines, points, and the border around shapes.
// strokeWeight(weight)

stroke(255, 0, 0);
strokeWeight(5);
ellipse(100, 100, 100, 100);

安装

CocoaPods

在你的Podfile中添加以下内容

  pod "HUDMakerKit"

Carthage

在你的Cartfile中添加以下内容

  github "natmark/HUDMakerKit"
  • 在Carthage/Build中将你的应用程序与HUDMakerKit.frameworkProcessingKit.framework链接

依赖关系

版权信息

HUDMakerKit遵循MIT许可证。有关更多信息,请参阅LICENSE文件。