Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

[iOS] Saves image with transparency mask #27

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

[iOS] Saves image with transparency mask #27

wants to merge 1 commit into from

Conversation

stefannew
Copy link

Saving images after removing the View container's background, or setting it to transparent would result in an all-black image after saving on iOS only.

This PR aims to resolve this by creating the image with a transparency mask.

I realize now that I've removed the scale option from the call to UIGraphicsBeginImageContext, so let me know if this poses problems.

This issue was also raised in Issue #23

Before:
before

After:
after

@@ -41,11 +41,17 @@ -(SketchFile *)saveToLocalCache

+ (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, [[UIScreen mainScreen] scale]);
UIGraphicsBeginImageContext(view.bounds.size);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppose I could use UIGraphicsBeginImageContextWithOptions with the opaque flag set to false, or pass in the parameter like before.

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

Successfully merging this pull request may close these issues.

1 participant