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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:13:36+00:00 2026-06-15T18:13:36+00:00

A UIImageVIew ( imageView ) is added to self.view , capturing the view to

  • 0

A UIImageVIew (imageView) is added to self.view, capturing the view to album works perfectly:

 CGSize size = CGSizeMake(self.view.frame.size.height, self.view.frame.size.width);
 UIGraphicsBeginImageContext(size);
 [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
 UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
 UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);

However, if the imageView subview is rotated by:

 [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

Capturing self.view again does not reflected the rotation. The subview imageView is as if not rotated.

How to make renderInContext works with subviews rotated by CABasicAnimation?

UPDATE:

Warning: The CALayer/-renderInContext: method doesn’t implement the
full Core Animation composition model. The code provided below will be
able to resolve most of the situations, but there are things that the
CALayer/-renderInContext: method doesn’t render correctly, so you may
wish to contact Developer Technical Support for workaround requests.

Official Apple Technical Q&A QA1703 suggested to contact Developer Technical Support for workaround requests.

Is there a workaround already existed?

  • 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-15T18:13:37+00:00Added an answer on June 15, 2026 at 6:13 pm

    Use layer.presentationLayer instead of layer when renderInContext.

    Here is a category for taking screenshots of UIView, UIView+Screenshot.h:

     //
     //  UIView+Screenshot.h
     //
     //  Created by Horace Ho on 2012/12/11.
     //  Copyright (c) 2012 Horace Ho. All rights reserved.
     //
     // Permission is hereby granted, free of charge, to any person obtaining a copy
     // of this software and associated documentation files (the "Software"), to deal
     // in the Software without restriction, including without limitation the rights
     // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     // copies of the Software, and to permit persons to whom the Software is
     // furnished to do so, subject to the following conditions:
     //
     // The above copyright notice and this permission notice shall be included in
     // all copies or substantial portions of the Software.
     //
     // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     // THE SOFTWARE.
    
     @interface UIView (HHScreenShot)
     - (UIImage *)screenshot:(UIDeviceOrientation)orientation isOpaque:(BOOL)isOpaque usePresentationLayer:(BOOL)usePresentationLayer;
     @end
    
     @implementation UIView (HHScreenShot)
    
     - (UIImage *)screenshot:(UIDeviceOrientation)orientation isOpaque:(BOOL)isOpaque usePresentationLayer:(BOOL)usePresentationLayer
     {
         CGSize size;
    
         if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown) {
             size = CGSizeMake(self.frame.size.width, self.frame.size.height);
         } else {
             size = CGSizeMake(self.frame.size.height, self.frame.size.width);
         }
    
         UIGraphicsBeginImageContextWithOptions(size, isOpaque, 0.0);
    
         if (usePresentationLayer) {
             [self.layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()];
         } else {
             [self.layer renderInContext:UIGraphicsGetCurrentContext()];
         }
    
         UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    
         UIGraphicsEndImageContext();
    
         return image;
     }
    
     @end
    

    To use:

     UIImage *image = [self.view screenshot:UIDeviceOrientationPortrait
                                   isOpaque:YES 
                       usePresentationLayer:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display an UIImageView using [self.view addSubview:imageView]; however nothing happens. imageView
How do UIImageView autoresize according to UIImage's size? imageView.image = image2; Now, the size
UIImage *image = [UIImage imageNamed:@logo_header.png]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.frame = CGRectMake(0,
I have one view controller in which I have added UIScrollView & UIImageView programatically.
I have one uiimageview which is added as subview in uiview. frame for uiimageview
ImageView is defined in class named Third - (void)viewDidLoad { // Displays UIImageView UIImageView*
Iam developing one application.In that iam using one uiimageview.And take another image view and
I have created one UIImageView Here's code capView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kARROW_CAP_NAME]]; capView.frame
I have added an UIImageView as a subview in UIView , and then I
- (void)fadeOutSplash { UIImageView *splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@Default-Landscape~ipad.png]]; [self.window.rootViewController.view addSubview:splash]; // <--

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.