Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds drawHierarchyInKeyWindow parameter #801

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jelizondo
Copy link

@Jelizondo Jelizondo commented Nov 2, 2023

What does this Pull Request do?

Adds the drawHeirarchyInKeyWindow parameter to the image method in UIViewController.swift file.

    public static func image(
      on config: ViewImageConfig,
      drawHierarchyInKeyWindow: Bool = false,
      precision: Float = 1,
      perceptualPrecision: Float = 1,
      size: CGSize? = nil,
      traits: UITraitCollection = .init()
    )
      -> Snapshotting
    {

      return SimplySnapshotting.image(
        precision: precision, perceptualPrecision: perceptualPrecision, scale: traits.displayScale
      ).asyncPullback { viewController in
        snapshotView(
          config: size.map { .init(safeArea: config.safeArea, size: $0, traits: config.traits) }
            ?? config,
          drawHierarchyInKeyWindow: drawHierarchyInKeyWindow,
          traits: traits,
          view: viewController.view,
          viewController: viewController
        )
      }
    }

We tried to extend the function in our project but got errors because snapshotView is private!

Use case:

Noticed other methods similar to this one had the drawHierarchyInKeyWindow parameter. For our use case we are using UIViewControllers as containers to SwiftUI views that contain UIVisualEffects. Without this parameter the UIVisualEffect would appear transparent in the snapshots.

Is this something we can add? Thanks!

@Jelizondo
Copy link
Author

Hello again! I would appreciate a review here! Is this something we can add? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant