Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7976599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:56:59+00:00 2026-06-04T08:56:59+00:00

In my app I have an Image which is shown to user and the

  • 0

In my app I have an Image which is shown to user and the overlay view with custom drawing by CoreGraphics. I want to save the image with overlay over it into CameraRoll.
So how should I make a new UIImage from existing UIImage and custom overlay view?

I tried to do it by creating the CGContextRef, drawing the UIImage into it, and then drawing the CALayer of the overlay view into the same context. But the UIImage which I get from this context is then just the overlay view over white background. It does’t seem to preserve transparency and just fills everything with white color.

How can it be fixed?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:57:01+00:00Added an answer on June 4, 2026 at 8:57 am

    If I understand your question right. You have two views

    1. An Image which is shown to user (i.e. viewA)
    2. The overlay view with custom drawing (i.e. viewB)

    If you create another view (i.e. viewC) addSubview viewA and viewB both on viewC.

    [viewC addSubview:viewA]

    [viewC addSubview:viewB]

    Now try CGContextRef on viewC

    UIImage *outputImage = [self convertViewToImage:viewC :1];
    

    convertViewToImage method:

    +(UIImage*)convertViewToImage:(UIView*)view:(float)ratio{
    UIGraphicsBeginImageContext(view.bounds.size);
    //UIGraphicsBeginImageContext(view.frame.size);
    
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], CGRectMake(0, 0, view.bounds.size.width*ratio, view.bounds.size.height*ratio));
    UIImage *targetImage = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);
    
    return targetImage;
    }
    

    I believe it will do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF app with an image over which is laid a user
I have an app in which the user can change the background image of
I have an app in which i want to implement a feature where user
Hi I have a gallery in my app which shows the image in an
I have an app which requires downloading image asynchronously in base64 encoded string(server is
I have a table where a user clicks on image to block/unblock user. which
I have a QGraphicsView contains a QGraphicsScene which loaded an image. What my app
In my app, I want to be able to have the user enter their
I want to show an image to the user when they launch the App.
I have an app which contain some images in res/drawable/ and shows them in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.