Particles 0.2.0

Particles 0.2.0

Ross KrasnerWyatt MufsonWyatt Mufson 维护。



Particles 0.2.0

  • 作者
  • WyattMufson

Particles

Build Status codecov Version License Platform

Particles是particles.js的原生Swift版本,受此StackOverflow问题的启发。

安装

Particles 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的Podfile中

pod 'Particles'

用法

您必须导入Particles包。

import Particles

let particlesView = ParticlesView(frame: view.frame)
view.addSubview(particlesView)

您还可以用三个可选参数初始化ParticlesView

var bgColor: UIColor = .clear                 // The color of the background of the view
var particlesColor: UIColor = .black          // The color of the particles and the lines connecting them
var density: ParticleDensity = .extraLight    // How densely packed the view is with particles
var speed: ParticleSpeed = .normal            // How fast the particles are moving

ParticleDensity枚举有五个情况

.extraLight
.light
.normal
.dense
.extraDense

ParticleSpeed枚举有三个情况

.quick
.normal
.slow

bgColorparticlesColordensityspeed可以在初始化后更改。更改密度不会导致粒子重新发射,但会根据新的density添加或删除所需的粒子数量。

示例

在ParticlesExample目标中提供了一个示例项目,以演示其功能。

默认的ParticlesView看起来像这样(具有黑色背景和白色粒子颜色)

defaultparticles

可根据您的具体喜好进行定制,例如像这样(蓝色背景和红色粒子颜色)

customparticles

许可证

《粒子》遵循MIT许可证