Skip to content

Commit

Permalink
Merge pull request #18 from lkzhao/stack-view-fix
Browse files Browse the repository at this point in the history
Temp fix for stack view
  • Loading branch information
lkzhao authored Jan 6, 2017
2 parents e83e19c + 7058500 commit 44b6c3b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Hero/HeroContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ extension HeroContext{
let oldCornerRadius = view.layer.cornerRadius
view.layer.cornerRadius = 0
let snapshot:UIView
if let imageView = view as? UIImageView{
if #available(iOS 9.0, *), let stackView = view as? UIStackView{
snapshot = stackView.slowSnapshotView()
} else if let imageView = view as? UIImageView{
let contentView = UIImageView(image: imageView.image)
contentView.frame = imageView.bounds
contentView.contentMode = imageView.contentMode
Expand Down
14 changes: 14 additions & 0 deletions Hero/UIKit+Hero.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ public extension UIView{
)
}
}

func slowSnapshotView() -> UIView{
UIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque, 0)
layer.render(in: UIGraphicsGetCurrentContext()!)
// drawHierarchy(in: bounds, afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

let imageView = UIImageView(image: image)
imageView.frame = bounds
let snapshotView = UIView(frame:bounds)
snapshotView.addSubview(imageView)
return snapshotView
}
}

public extension UIViewController{
Expand Down

0 comments on commit 44b6c3b

Please sign in to comment.