Skip to content

Commit

Permalink
Use custom snapshot for views that implements HeroCustomSnapshotView
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel G-Estañ committed Dec 18, 2018
1 parent d0a0ef8 commit be8cc65
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/HeroContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ extension HeroContext {
#if os(tvOS)
snapshot = view.snapshotView(afterScreenUpdates: true)!
#else
if #available(iOS 9.0, *), let stackView = view as? UIStackView {
if let customSnapshotView = view as? HeroCustomSnapshotView, let snapshotView = customSnapshotView.heroSnapshot {
snapshot = snapshotView
} else if #available(iOS 9.0, *), let stackView = view as? UIStackView {
snapshot = stackView.slowSnapshotView()
} else if let imageView = view as? UIImageView, view.subviews.isEmpty {
let contentView = UIImageView(image: imageView.image)
Expand Down Expand Up @@ -388,3 +390,8 @@ extension HeroContext {
}
}
}

/// Allows a view to create their own custom snapshot when using **Optimized** snapshot
public protocol HeroCustomSnapshotView {
var heroSnapshot: UIView? { get }
}

0 comments on commit be8cc65

Please sign in to comment.