Commit 9842a65b by Daniel Dahan

development: added backgroundColor to MotionTransition

parent 7be4d2c2
...@@ -133,9 +133,15 @@ extension UIView { ...@@ -133,9 +133,15 @@ extension UIView {
let oldCornerRadius = cornerRadius let oldCornerRadius = cornerRadius
cornerRadius = 0 cornerRadius = 0
let oldBackgroundColor = backgroundColor
backgroundColor = .clear
let v = snapshotView(afterScreenUpdates: afterUpdates)! let v = snapshotView(afterScreenUpdates: afterUpdates)!
cornerRadius = oldCornerRadius cornerRadius = oldCornerRadius
backgroundColor = oldBackgroundColor
v.backgroundColor = oldBackgroundColor
let contentView = v.subviews.first! let contentView = v.subviews.first!
contentView.cornerRadius = cornerRadius contentView.cornerRadius = cornerRadius
contentView.masksToBounds = true contentView.masksToBounds = true
...@@ -149,7 +155,6 @@ extension UIView { ...@@ -149,7 +155,6 @@ extension UIView {
v.isOpaque = isOpaque v.isOpaque = isOpaque
v.anchorPoint = anchorPoint v.anchorPoint = anchorPoint
v.masksToBounds = masksToBounds v.masksToBounds = masksToBounds
v.backgroundColor = backgroundColor
v.borderColor = borderColor v.borderColor = borderColor
v.borderWidth = borderWidth v.borderWidth = borderWidth
v.shadowRadius = shadowRadius v.shadowRadius = shadowRadius
...@@ -207,6 +212,8 @@ open class MotionTransitionPresentationController: UIPresentationController { ...@@ -207,6 +212,8 @@ open class MotionTransitionPresentationController: UIPresentationController {
open class MotionTransition: NSObject { open class MotionTransition: NSObject {
open var isPresenting = false open var isPresenting = false
open let backgroundView = UIView()
open var toViewController: UIViewController! open var toViewController: UIViewController!
open var fromViewController: UIViewController! open var fromViewController: UIViewController!
...@@ -324,8 +331,6 @@ extension MotionTransition: UIViewControllerAnimatedTransitioning { ...@@ -324,8 +331,6 @@ extension MotionTransition: UIViewControllerAnimatedTransitioning {
} }
open class MotionTransitionPresentedAnimator: MotionTransition { open class MotionTransitionPresentedAnimator: MotionTransition {
open let backgroundView = UIView()
@objc(animateTransition:) @objc(animateTransition:)
open override func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { open override func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
super.animateTransition(using: transitionContext) super.animateTransition(using: transitionContext)
...@@ -376,6 +381,8 @@ open class MotionTransitionPresentedAnimator: MotionTransition { ...@@ -376,6 +381,8 @@ open class MotionTransitionPresentedAnimator: MotionTransition {
snapshotAnimations.append(Motion.rotate(angle: tv.motionRotationAngle)) snapshotAnimations.append(Motion.rotate(angle: tv.motionRotationAngle))
snapshotAnimations.append(Motion.background(color: tv.backgroundColor ?? .clear))
let cornerRadiusAnimation = Motion.corner(radius: tv.cornerRadius) let cornerRadiusAnimation = Motion.corner(radius: tv.cornerRadius)
snapshotAnimations.append(cornerRadiusAnimation) snapshotAnimations.append(cornerRadiusAnimation)
snapshotChildAnimations.append(cornerRadiusAnimation) snapshotChildAnimations.append(cornerRadiusAnimation)
...@@ -443,10 +450,9 @@ open class MotionTransitionDismissedAnimator: MotionTransition { ...@@ -443,10 +450,9 @@ open class MotionTransitionDismissedAnimator: MotionTransition {
transitionView.isHidden = true transitionView.isHidden = true
let bgView = UIView() backgroundView.backgroundColor = fromView.backgroundColor
bgView.backgroundColor = fromView.backgroundColor backgroundView.frame = transitionView.bounds
bgView.frame = transitionView.bounds transitionView.addSubview(backgroundView)
transitionView.addSubview(bgView)
toView.updateConstraints() toView.updateConstraints()
toView.setNeedsLayout() toView.setNeedsLayout()
...@@ -487,6 +493,8 @@ open class MotionTransitionDismissedAnimator: MotionTransition { ...@@ -487,6 +493,8 @@ open class MotionTransitionDismissedAnimator: MotionTransition {
snapshotAnimations.append(Motion.rotate(angle: tv.motionRotationAngle)) snapshotAnimations.append(Motion.rotate(angle: tv.motionRotationAngle))
snapshotAnimations.append(Motion.background(color: tv.backgroundColor ?? .clear))
let cornerRadiusAnimation = Motion.corner(radius: tv.cornerRadius) let cornerRadiusAnimation = Motion.corner(radius: tv.cornerRadius)
snapshotAnimations.append(cornerRadiusAnimation) snapshotAnimations.append(cornerRadiusAnimation)
snapshotChildAnimations.append(cornerRadiusAnimation) snapshotChildAnimations.append(cornerRadiusAnimation)
...@@ -526,8 +534,8 @@ open class MotionTransitionDismissedAnimator: MotionTransition { ...@@ -526,8 +534,8 @@ open class MotionTransitionDismissedAnimator: MotionTransition {
let d = transitionDuration(using: transitionContext) let d = transitionDuration(using: transitionContext)
if nil != bgView.backgroundColor { if nil != backgroundView.backgroundColor {
bgView.motion(.backgroundColor(.clear), .duration(d)) backgroundView.motion(.backgroundColor(.clear), .duration(d))
} }
Motion.delay(d) { [weak self] in Motion.delay(d) { [weak self] in
......
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