Skip to content

Commit

Permalink
Fixed Shadow Issues
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
2blane committed Apr 4, 2018
1 parent e5f771c commit 590a9f9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/HeroContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ 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
view.layer.cornerRadius = 0
view.alpha = 1
view.layer.shadowRadius = 0.0
view.layer.shadowOffset = .zero
view.layer.shadowPath = nil

let snapshot: UIView
let snapshotType: HeroSnapshotType = self[view]?.snapshotType ?? .optimized
Expand Down Expand Up @@ -210,6 +216,9 @@ extension HeroContext {

view.layer.cornerRadius = oldCornerRadius
view.alpha = oldAlpha
view.layer.shadowRadius = oldShadowRadius
view.layer.shadowOffset = oldShadowOffset
view.layer.shadowPath = oldShadowPath

snapshot.layer.anchorPoint = view.layer.anchorPoint
snapshot.layer.position = containerView.convert(view.layer.position, from: view.superview!)
Expand Down

0 comments on commit 590a9f9

Please sign in to comment.