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 3427198
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:48:27+00:00 2026-05-18T06:48:27+00:00

I have an UIView with many UIImageViews as subviews. The app runs on iOS4

  • 0

I have an UIView with many UIImageViews as subviews. The app runs on iOS4 and I use images with retina display resolution (i.e. the images load with scale = 2)

I want to save the contents of the UIView … BUT … have the real size of the images inside. I.e. the view has size 200×200 and images with scale=2 inside, I’d like to save a resulting image of 400×400 and all the images with their real size.

Now what comes first to mind is to create a new image context and load again all images inside with scale=1 and that should do, but I was wondering if there is any more elegant way to do that? Seems like a waist of memory and processor time to reload everything again since it’s already done …

p.s. if anyone has an answer – including code would be nice

  • 1 1 Answer
  • 1 View
  • 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-05-18T06:48:28+00:00Added an answer on May 18, 2026 at 6:48 am

    Implementation for rendering any UIView to image (working also for retina display).

    helper.h file:

    @interface UIView (Ext) 
    - (UIImage*) renderToImage;
    @end
    

    and belonging implementation in helper.m file:

    #import <QuartzCore/QuartzCore.h>
    
    @implementation UIView (Ext)
    - (UIImage*) renderToImage
    {
      // IMPORTANT: using weak link on UIKit
      if(UIGraphicsBeginImageContextWithOptions != NULL)
      {
        UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
      } else {
        UIGraphicsBeginImageContext(self.frame.size);
      }
    
      [self.layer renderInContext:UIGraphicsGetCurrentContext()];
      UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();  
      return image;
    }
    

    0.0 is the scale factor. The scale factor to apply to the bitmap. If you specify a value of 0.0, the scale factor is set to the scale factor of the device’s main screen.

    QuartzCore.framework also should be put into the project because we are calling function on the layer object.

    To enable weak link on UIKit framework, click on the project item in left navigator, click the project target -> build phases -> link binary and choose “optional” (weak) type on UIKit framework.

    Here is library with similar extensions for UIColor, UIImage, NSArray, NSDictionary, …

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

Sidebar

Related Questions

I have a custom UIView which is composed of many images, their positions are
I'm developing an app that i need to load many images in a view
Since I have to draw many points in a UIview, I'd like to display
In my app i have one UIViewController and there are many UIView which i
I currently have a simple iPhone app that loads a custom subclass of UIView.
I have some a UIView with several user created subviews. The user can move
I have a Main View Controller that has many subviews. What I want is
I have a UIView where has so many elements like Text Field, Date Picker,
I have a scrollView with a UIView as subview, which in turn has many
I have a UIView which contains many items like UIScrollView. How can I specify

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.