Camera and media editor improvements

This commit is contained in:
Ilya Laktyushin
2023-05-10 17:10:27 +04:00
parent c114f218b9
commit d15c48ff07
104 changed files with 9805 additions and 676 deletions

View File

@@ -739,6 +739,34 @@ public struct Transition {
}
}
public func setShapeLayerFillColor(layer: CAShapeLayer, color: UIColor, completion: ((Bool) -> Void)? = nil) {
if let current = layer.layerTintColor, current == color.cgColor {
completion?(true)
return
}
switch self.animation {
case .none:
layer.fillColor = color.cgColor
completion?(true)
case let .curve(duration, curve):
let previousColor: CGColor = layer.fillColor ?? UIColor.clear.cgColor
layer.fillColor = color.cgColor
layer.animate(
from: previousColor,
to: color.cgColor,
keyPath: "fillColor",
duration: duration,
delay: 0.0,
curve: curve,
removeOnCompletion: true,
additive: false,
completion: completion
)
}
}
public func setBackgroundColor(view: UIView, color: UIColor, completion: ((Bool) -> Void)? = nil) {
self.setBackgroundColor(layer: view.layer, color: color, completion: completion)
}