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

Ability to disable alpha channel from image snapshots #761

Open
NachoSoto opened this issue Aug 28, 2023 · 1 comment
Open

Ability to disable alpha channel from image snapshots #761

NachoSoto opened this issue Aug 28, 2023 · 1 comment

Comments

@NachoSoto
Copy link
Contributor

Looks like there is no way to make snapshots opaque? It would save a lot of space to remove the alpha channel when not needed.

@CraigSiemens
Copy link

We wanted this as well, though for a different reason #673 (comment)

We made a custom Snapshotting instance named opaqueImage that always adds a white background to the image. I'm not sure it reduces the file size, but it's a step closer to being able to do that.

Snapshotting<UIView, UIImage>
    .image(
        size: size,
        traits: traits
    )
    .pullback { view in
        let backgroundView = UIView(frame: view.frame)
        backgroundView.backgroundColor = .white
        backgroundView.preservesSuperviewLayoutMargins = true
        backgroundView.addSubview(view)
        return backgroundView
    }

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

No branches or pull requests

2 participants