mirror of
https://github.com/sparrowcode/AlertKit.git
synced 2026-06-16 12:44:37 +00:00
52 lines
2.3 KiB
Swift
52 lines
2.3 KiB
Swift
// The MIT License (MIT)
|
|
// Copyright © 2020 Ivan Vorobei (hello@ivanvorobei.by)
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
// copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
|
|
import UIKit
|
|
|
|
public class SPAlertIconDoneView: UIView, SPAlertIconAnimatable {
|
|
|
|
public func animate() {
|
|
let length = frame.width
|
|
let animatablePath = UIBezierPath()
|
|
animatablePath.move(to: CGPoint(x: length * 0.196, y: length * 0.527))
|
|
animatablePath.addLine(to: CGPoint(x: length * 0.47, y: length * 0.777))
|
|
animatablePath.addLine(to: CGPoint(x: length * 0.99, y: length * 0.25))
|
|
|
|
let animatableLayer = CAShapeLayer()
|
|
animatableLayer.path = animatablePath.cgPath
|
|
animatableLayer.fillColor = UIColor.clear.cgColor
|
|
animatableLayer.strokeColor = tintColor?.cgColor
|
|
animatableLayer.lineWidth = 9
|
|
animatableLayer.lineCap = .round
|
|
animatableLayer.lineJoin = .round
|
|
animatableLayer.strokeEnd = 0
|
|
layer.addSublayer(animatableLayer)
|
|
|
|
let animation = CABasicAnimation(keyPath: "strokeEnd")
|
|
animation.duration = 0.3
|
|
animation.fromValue = 0
|
|
animation.toValue = 1
|
|
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
|
|
animatableLayer.strokeEnd = 1
|
|
animatableLayer.add(animation, forKey: "animation")
|
|
}
|
|
}
|