Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Shadow Issues #440

Merged
merged 4 commits into from
Apr 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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