几何活动指示器 0.1.1

几何活动指示器 0.1.1

Duncan MacDonald维护。




几何活动指示器

CI Status Version License Platform

安装

几何活动指示器可通过CocoaPods使用。要安装它,只需将以下行添加到Podfile中

pod 'GeometricActivityIndicator'

示例

要运行示例项目,请克隆仓库,然后首先从示例目录中运行pod install命令。

动画

几何活动指示器中的动画基于Metatron's Solids/Sacred Geometry

shapes

用法

故事板

在项目中实现GeometricActivityIndicator,就像为UIView设置一个自定义类。许多属性都可以通过属性检查器进行编辑。

storyboard

在您的ViewController中

// create an IBOutlet for your new GeometricActivityIndicator
@IBOutlet weak var geometricView: GeometricActivityIndicator!

// now you can start / stop animating
override func viewDidLoad() {
    geometricView.startAnimating()
}

@IBAction func stopButtonTapped(_ sender: Any) {
    geometricView.stopAnimating()
}

重要:GeometricActivityIndicator是UIView的子类,而不是UIActivityIndicatorView,请确保您为正确的元素设置了自定义类。

编程方式

class ViewController: UIViewController {
    var geometricView: GeometricActivityIndicator!

    override func viewDidLoad() {
        geometricView = GeometricActivityIndicator(frame: CGRect(x: 0, y: 0, width: 250, height: 250))

        geometricView.startAnimating()
    }

    @IBAction func stopButtonTapped(_ sender: Any) {
        geometricView.stopAnimating()
    }
}

自定义

改变动画时间

改变时长

// changes the stencil animation duration to 3 seconds
geometricView.stencilAnimDuration = 3
// changes the shape animation duration to 5 seconds
geometricView.shapeAnimDuration = 5

改变动画时间

// changes stencil animation and shape animation to start and end at the same time with a duration of 3 seconds
geometricView.stencilAnimDuration  = 3
geometricView.stencilAnimFromValue = 0
geometricView.stencilAnimToValue   = 1

geometricView.shapeAnimDuration    = 3
geometricView.shapeAnimFromValue   = 0
geometricView.shapeAnimToValue     = 1
// this is the default duration and timing for the stencil and shape animations
// note: these are the default values when creating a GeometricActivityIndicator.
//       these values produce the animations shown above
geometricView.stencilAnimDuration  =  1.5
geometricView.stencilAnimFromValue = -0.5
geometricView.stencilAnimToValue   =  2

geometricView.shapeAnimDuration    =  1.5
geometricView.shapeAnimFromValue   = -2
geometricView.shapeAnimToValue     =  1.5

作者

oct0f1sh, [email protected]

许可

几何活动指示器可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。