Commit 402084c6 by Daniel Dahan

development: fixed issue that when view was rotated it would not calculate the…

development: fixed issue that when view was rotated it would not calculate the cornerRadius correctly
parent 5930fa6f
...@@ -258,12 +258,10 @@ extension CALayer { ...@@ -258,12 +258,10 @@ extension CALayer {
- Parameter animation: A CAAnimation instance. - Parameter animation: A CAAnimation instance.
*/ */
open func animate(animation: CAAnimation) { open func animate(animation: CAAnimation) {
if #available(iOS 10, *) { animation.delegate = self
animation.delegate = self
}
if let a = animation as? CABasicAnimation { if let a = animation as? CABasicAnimation {
a.fromValue = (nil == presentation() ? self : presentation()!).value(forKeyPath: a.keyPath!) a.fromValue = (presentation() ?? self).value(forKeyPath: a.keyPath!)
} }
if let a = animation as? CAPropertyAnimation { if let a = animation as? CAPropertyAnimation {
...@@ -320,7 +318,7 @@ extension CALayer { ...@@ -320,7 +318,7 @@ extension CALayer {
} }
if .circle == shapePreset { if .circle == shapePreset {
cornerRadius = width / 2 cornerRadius = bounds.size.width / 2
} }
} }
...@@ -343,6 +341,4 @@ extension CALayer { ...@@ -343,6 +341,4 @@ extension CALayer {
} }
@available(iOS 10, *) @available(iOS 10, *)
extension CALayer: CAAnimationDelegate { extension CALayer: CAAnimationDelegate {}
}
...@@ -185,9 +185,9 @@ extension Motion { ...@@ -185,9 +185,9 @@ extension Motion {
public static func rotateY(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation { public static func rotateY(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationY) let animation = CABasicAnimation(keyPath: .rotationY)
if let v: CGFloat = angle { if let v = angle {
animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber
} else if let v: CGFloat = rotation { } else if let v = rotation {
animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber
} }
...@@ -212,9 +212,9 @@ extension Motion { ...@@ -212,9 +212,9 @@ extension Motion {
public static func rotateZ(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation { public static func rotateZ(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationZ) let animation = CABasicAnimation(keyPath: .rotationZ)
if let v: CGFloat = angle { if let v = angle {
animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber
} else if let v: CGFloat = rotation { } else if let v = rotation {
animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment