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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:23:02+00:00 2026-05-19T15:23:02+00:00

The way to load image to the layer is simply this: CALayer *layer =

  • 0

The way to load image to the layer is simply this:

CALayer *layer = [[CALayer alloc]init];

layer.contents = (id) [UIImage imageNamed:@"image.png"].CGImage;

then you add the layer as sublayer to the view something like:

assume you in the view

[self.layer addSublayer:layer];

Now I want to load an array of image as animation so eventually I will get the images animated.

so before actually perform the animation I have tested the following:

[values insertObject:(id)[UIImage imageNamed:path].CGImage atIndex:i];

of course there is a loop that that runs that enter each image to the right index… and then I am getting an array of CGImage .. for the animation.

I have printed this array and saw this:

CGImage 0x17d900

CGImage 0x17f4e0

So the values are there.. and I am not getting any errors .. but I do not see the images…

Let me know if you have an idea ….

  • 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-05-19T15:23:02+00:00Added an answer on May 19, 2026 at 3:23 pm

    This is a code snippet which worked fine for one of my projects:

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath: @"contents"];
    animation.calculationMode = kCAAnimationDiscrete;
    animation.duration = 1.0;
    animation.values = values; // NSArray of CGImageRefs
    [layer addAnimation: animation forKey: @"contents"];
    

    However, I had largish images for animation frames and on old iPhones/iPods that caused serious performance problems. If you run into this, the secret ingredient is to use the pre-rendered images (IIRC, they are represented with a private CABackingStore class). In a nutshell, you make a CALayer of the correct size, which uses drawInContext: to draw a single animation frame, then you loop through the animation frames, where you feed the layer a frame image, send it display and save its contents property into an array. The caching technique is safe as long as you don’t try to manipulate the pre-rendered images in any way: basically, you simply do layer1.contents = layer2.contents.

    Just don’t waste your time implementing the above unless you do have performance problems.

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

Sidebar

Related Questions

I'm looking for a way to load up an existing png image, and do
When a user is uploading an image, is there a way I can load
In one webpage, I have a big image to load and other contents. Sometimes
Is there an efficient way to load an image into a model class? The
I use this code to load an image into matlab axes in gui :
Im doing this to load image and show image inside a dialog box. <div
What's the best way to load HTML markup for a custom jQuery UI widget?
What is the proper way to load a ListBox in C# .NET 2.0 Winforms?
What is the best way to load static data files containing game level maps
I am trying to find a way to load a JSON page to display

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.