Skip to content

Commit

Permalink
Fixed Shadow Issues (#440)
Browse files Browse the repository at this point in the history
* 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 d9f0020.

* Added/Fixed Shadow Opacity

This reverts commit 590a9f9.
  • Loading branch information
2blane authored and lkzhao committed Apr 27, 2018
1 parent 6ff3a59 commit 7d61342
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Sources/HeroContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!)
Expand Down

0 comments on commit 7d61342

Please sign in to comment.