Skip to content

Commit

Permalink
bgayman#6 Fix rendering an image from view
Browse files Browse the repository at this point in the history
  • Loading branch information
abekert committed Jun 1, 2022
1 parent bd9f29c commit 5c82571
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Sources/FlipBook/View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ extension View {
}

func fb_makeViewSnapshot() -> Image? {
UIGraphicsBeginImageContextWithOptions(frame.size, true, 0)
guard let context = UIGraphicsGetCurrentContext() else { return nil }
layer.presentation()?.render(in: context)
let rasterizedView = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return rasterizedView
UIGraphicsImageRenderer(size: bounds.size).image { rendererContext in
drawHierarchy(in: bounds, afterScreenUpdates: false)
}
}
}
#endif

0 comments on commit 5c82571

Please sign in to comment.