Comets 0.3.1

Comets 0.3.1

DeviceLayout维护。



Comets 0.3.1

  • 作者:
  • cruz

Comets

☄️Comets: 使用Swift在iOS中动画粒子

Swift Version License Platform Carthage compatible

comet.gif

动画由kevin作为Voicy设计的一部分制作。

实现了medium上的《Comets: 使用Swift在iOS中动画粒子》功能。

示例

// Customize your comet
let width = view.bounds.width
let height = view.bounds.height
let comets = [Comet(startPoint: CGPoint(x: 100, y: 0),
                    endPoint: CGPoint(x: 0, y: 100),
                    lineColor: UIColor.white.withAlphaComponent(0.2),
                    cometColor: UIColor.white),
              Comet(startPoint: CGPoint(x: 0.4 * width, y: 0),
                    endPoint: CGPoint(x: width, y: 0.8 * width),
                    lineColor: UIColor.white.withAlphaComponent(0.2),
                    cometColor: UIColor.white),
              Comet(startPoint: CGPoint(x: 0.8 * width, y: 0),
                    endPoint: CGPoint(x: width, y: 0.2 * width),
                    lineColor: UIColor.white.withAlphaComponent(0.2),
                    cometColor: UIColor.white),
              Comet(startPoint: CGPoint(x: width, y: 0.2 * height),
                    endPoint: CGPoint(x: 0, y: 0.25 * height),
                    lineColor: UIColor.white.withAlphaComponent(0.2),
                    cometColor: UIColor.white),
              Comet(startPoint: CGPoint(x: 0, y: height - 0.8 * width),
                    endPoint: CGPoint(x: 0.6 * width, y: height),
                    lineColor: UIColor.white.withAlphaComponent(0.2),
                    cometColor: UIColor.white),
              Comet(startPoint: CGPoint(x: width - 100, y: height),
                    endPoint: CGPoint(x: width, y: height - 100),
                    lineColor: UIColor.white.withAlphaComponent(0.2),
                    cometColor: UIColor.white),
              Comet(startPoint: CGPoint(x: 0, y: 0.8 * height),
                    endPoint: CGPoint(x: width, y: 0.75 * height),
                    lineColor: UIColor.white.withAlphaComponent(0.2),
                    cometColor: UIColor.white)]

// draw line track and animate
for comet in comets {
    view.layer.addSublayer(comet.drawLine())
    view.layer.addSublayer(comet.animate())
}

comet.gif

要求

Comets是用Xcode 10、Swift 5.0、iOS 9.0编写的,需要这些版本

📲安装

Comets可以通过CocoapodsCarthage使用。

Cocoapods

pod "Comets"

Carthage

github "cruisediary/Comets" ~> 0.3.1

❤️贡献

总是欢迎拉取请求 🏄🏼

👨‍💻作者

克鲁兹,[email protected]

🛡许可协议

Comets 可在 MIT 许可协议下使用。有关更多信息,请参阅 LICENSE 文件。