Skip to content

Commit

Permalink
Use custom snapshot for views that implements HeroCustomSnapshotView (#…
Browse files Browse the repository at this point in the history
…541)

* Use custom snapshot for views that implements HeroCustomSnapshotView

* Update CHANGELOG.md

* Update CHANGELOG and move to correct section
  • Loading branch information
ManueGE authored and SD10 committed Dec 27, 2018
1 parent faf8475 commit 07ef883
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The changelog for `Hero`. Also see the [releases](https://github.com/HeroTransit

## Upcoming release

### Added

- Use custom snapshot for views that implement `HeroCustomSnapshotView`.
[#541](https://github.com/HeroTransitions/Hero/pull/541) by [@ManueGE](https://github.com/ManueGE)

### Changed

- Added support for right to left languages.
Expand All @@ -21,6 +26,7 @@ The changelog for `Hero`. Also see the [releases](https://github.com/HeroTransit
- Added support for Swift 4.2.
[#534](https://github.com/HeroTransitions/Hero/pull/534) by [@rennarda](https://github.com/rennarda)


## [1.3.1](https://github.com/HeroTransitions/Hero/releases/tag/1.3.1)

### Fixed
Expand Down
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.filter({!$0.isHidden}).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 07ef883

Please sign in to comment.