Camera and editor improvements

This commit is contained in:
Ilya Laktyushin
2023-06-03 01:19:23 +04:00
parent 3df2d3cad5
commit ab69b9e982
48 changed files with 2154 additions and 557 deletions

View File

@@ -825,6 +825,52 @@ public struct Transition {
}
}
public func setShapeLayerStrokeStart(layer: CAShapeLayer, strokeStart: CGFloat, completion: ((Bool) -> Void)? = nil) {
switch self.animation {
case .none:
layer.strokeStart = strokeStart
completion?(true)
case let .curve(duration, curve):
let previousStrokeStart = layer.strokeStart
layer.strokeStart = strokeStart
layer.animate(
from: previousStrokeStart as NSNumber,
to: strokeStart as NSNumber,
keyPath: "strokeStart",
duration: duration,
delay: 0.0,
curve: curve,
removeOnCompletion: true,
additive: false,
completion: completion
)
}
}
public func setShapeLayerStrokeEnd(layer: CAShapeLayer, strokeEnd: CGFloat, completion: ((Bool) -> Void)? = nil) {
switch self.animation {
case .none:
layer.strokeEnd = strokeEnd
completion?(true)
case let .curve(duration, curve):
let previousStrokeEnd = layer.strokeEnd
layer.strokeEnd = strokeEnd
layer.animate(
from: previousStrokeEnd as NSNumber,
to: strokeEnd as NSNumber,
keyPath: "strokeEnd",
duration: duration,
delay: 0.0,
curve: curve,
removeOnCompletion: true,
additive: false,
completion: completion
)
}
}
public func setShapeLayerFillColor(layer: CAShapeLayer, color: UIColor, completion: ((Bool) -> Void)? = nil) {
if let current = layer.layerTintColor, current == color.cgColor {
completion?(true)