0

Okay, sorry if the title is a little confusing. Basically I am trying get the image/subviews of the image view and combine them into a single exportable UIImage.

Here is my current code, however it has a large resolution loss.

func generateImage() -> UIImage{
    UIGraphicsBeginImageContext(environmentImageView.frame.size)
    var context : CGContextRef = UIGraphicsGetCurrentContext()
    environmentImageView.layer.renderInContext(context)
    var img : UIImage = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return img
}

1 Answer 1

1

You have to set the scale of the context to be retina.

UIGraphicsBeginImageContextWithOptions(environmentImageView.frame.size, false, 0)

0 means to use the scale of the screen which will work for non-retina devices as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.