Skip to content

Commit

Permalink
[temp] fix animation for UIVisualEffectView
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-dumit committed Jan 8, 2017
1 parent dbadcdc commit 7d9f0f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Hero/HeroContext.swift
Expand Up @@ -98,6 +98,14 @@ extension HeroContext{
let snapshot:UIView
if #available(iOS 9.0, *), let stackView = view as? UIStackView{
snapshot = stackView.slowSnapshotView()
} else if let effectView = view as? UIVisualEffectView {
let backgroundView = view.window!.slowSnapshotView(bounds: effectView.bounds)
let contentView = UIVisualEffectView(effect: effectView.effect)
contentView.frame = effectView.bounds
let snapshotView = UIView()
snapshotView.addSubview(backgroundView)
snapshotView.addSubview(contentView)
snapshot = snapshotView
} else if let imageView = view as? UIImageView{
let contentView = UIImageView(image: imageView.image)
contentView.frame = imageView.bounds
Expand Down
3 changes: 2 additions & 1 deletion Hero/UIKit+Hero.swift
Expand Up @@ -95,7 +95,8 @@ public extension UIView{
}
}

func slowSnapshotView() -> UIView{
func slowSnapshotView(bounds: CGRect? = nil) -> UIView{
let bounds = bounds ?? self.bounds
UIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque, 0)
layer.render(in: UIGraphicsGetCurrentContext()!)
// drawHierarchy(in: bounds, afterScreenUpdates: true)
Expand Down

0 comments on commit 7d9f0f1

Please sign in to comment.