Add boundsProvider parameter to renderToImage function

This commit is contained in:
KK 2026-01-08 17:50:15 +08:00 committed by GitHub
parent 07b8d96e19
commit 38b32bde58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,9 +39,10 @@ public extension SkeletonDrawableWrapper {
/// - size: The size of the `CGImage` that should be rendered. /// - size: The size of the `CGImage` that should be rendered.
/// - backgroundColor: the background color of the image /// - backgroundColor: the background color of the image
/// - scaleFactor: The scale factor. Set this to `UIScreen.main.scale` if you want to show the image in a view /// - scaleFactor: The scale factor. Set this to `UIScreen.main.scale` if you want to show the image in a view
func renderToImage(size: CGSize, backgroundColor: UIColor, scaleFactor: CGFloat = 1) throws -> CGImage? { func renderToImage(size: CGSize, boundsProvider: BoundsProvider = SetupPoseBounds(), backgroundColor: UIColor, scaleFactor: CGFloat = 1) throws -> CGImage? {
let spineView = SpineUIView( let spineView = SpineUIView(
controller: SpineController(disposeDrawableOnDeInit: false), // Doesn't own the drawable controller: SpineController(disposeDrawableOnDeInit: false), // Doesn't own the drawable
boundsProvider: boundsProvider,
backgroundColor: backgroundColor backgroundColor: backgroundColor
) )
spineView.frame = CGRect(origin: .zero, size: size) spineView.frame = CGRect(origin: .zero, size: size)