From 7d613424075702281eb6b94213eeffe3a7a3a95b Mon Sep 17 00:00:00 2001 From: Blane Townsend Date: Thu, 26 Apr 2018 22:26:54 -0500 Subject: [PATCH] Fixed Shadow Issues (#440) * Fixed Shadow Issues Shadows were being cutoff by the snapshots, and then were applied again to the snapshot. This fix first removes the shadows, takes the snapshot, and then adds the shadows to the snapshot much like the cornerRadius. * added shadow opacity * Revert "added shadow opacity" This reverts commit d9f0020dbbd7c6ceb11f3999d557cfc59cc9cda6. * Added/Fixed Shadow Opacity This reverts commit 590a9f9377a628ed8fabd20cf1a57572c3c96656. --- Sources/HeroContext.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Sources/HeroContext.swift b/Sources/HeroContext.swift index c0cea003..8246cc9b 100644 --- a/Sources/HeroContext.swift +++ b/Sources/HeroContext.swift @@ -138,11 +138,19 @@ extension HeroContext { unhide(view: view) - // capture a snapshot without alpha & cornerRadius + // capture a snapshot without alpha, cornerRadius, or shadows let oldCornerRadius = view.layer.cornerRadius let oldAlpha = view.alpha + let oldShadowRadius = view.layer.shadowRadius + let oldShadowOffset = view.layer.shadowOffset + let oldShadowPath = view.layer.shadowPath + let oldShadowOpacity = view.layer.shadowOpacity view.layer.cornerRadius = 0 view.alpha = 1 + view.layer.shadowRadius = 0.0 + view.layer.shadowOffset = .zero + view.layer.shadowPath = nil + view.layer.shadowOpacity = 0.0 let snapshot: UIView let snapshotType: HeroSnapshotType = self[view]?.snapshotType ?? .optimized @@ -210,6 +218,10 @@ extension HeroContext { view.layer.cornerRadius = oldCornerRadius view.alpha = oldAlpha + view.layer.shadowRadius = oldShadowRadius + view.layer.shadowOffset = oldShadowOffset + view.layer.shadowPath = oldShadowPath + view.layer.shadowOpacity = oldShadowOpacity snapshot.layer.anchorPoint = view.layer.anchorPoint snapshot.layer.position = containerView.convert(view.layer.position, from: view.superview!)