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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:11:16+00:00 2026-05-13T09:11:16+00:00

I’m developing a game in which I want my image to reduce in size

  • 0

I’m developing a game in which I want my image to reduce in size gradually. I’m reducing the frame size gradually in my code when it works fine. [I’ve already used CGAffineTransform and it doesn’t suit my requirement.]

-(void)function     
{
    ravanImage1.frame=CGRectMake(150,((ravanImage1.frame.origin.y)-5),q,z);

    if(ravanImage1.center.y>=300&&ravanImage1.center.y<=370)
    {
        q=60;
        z=60;
        ravanImage1.frame=CGRectMake(150,((ravanImage1.frame.origin.y)-5),q,z);
    }   

    if(ravanImage1.center.y>=230&&ravanImage1.center.y<=299)
    {
        q=40;
        z=40;
        ravanImage1.frame=CGRectMake(150,((ravanImage1.frame.origin.y)-5),q,z);
    }

    if(ravanImage1.center.y>=150&&ravanImage1.center.y<=229)
    {   
        q=20;
        z=20;
        ravanImage1.frame=CGRectMake(150,((ravanImage1.frame.origin.y)-5),q,z);
    }
}

But when I apply a while loop for the same code specifying wheather at what point to stop reducing the frame(“while that point isn’t reached”), it doesn’t show the image frame reduction little by little as it shows it otherwise, but directly places the image at the end point with proper frame.
I want it to get displyed the way it gets without the while loop i.e. reduction little by little. Yes, while debugging it steps through all the steps properly.
Can anybody please help me?

  • 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-13T09:11:17+00:00Added an answer on May 13, 2026 at 9:11 am

    As others have pointed out, manually adjusting the frame of your view will give you terrible performance. If you really don’t want to use a standard UIView animation block for changing your view, you can specify bounds size values to animate through using a CAKeyframeAnimation applied to your view’s layer:

    CAKeyframeAnimation * customSizeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"bounds.size"];
    NSArray *sizeValues = [NSArray arrayWithObjects:[NSValue valueWithCGSize:size1], [NSValue valueWithCGSize:size2], [NSValue valueWithCGSize:size3], nil];
    [customSizeAnimation setValues:frameValues];
    NSArray *times = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f], [NSNumber numberWithFloat:0.5f], [NSNumber numberWithFloat:1.0f], nil]; 
    [customSizeAnimation setKeyTimes:times];
    customSizeAnimation.fillMode = kCAFillModeForwards;
    customSizeAnimation.removedOnCompletion = NO;
    [view.layer addAnimation: customSizeAnimation forKey:@"customSizeAnimation"];
    

    This animation will start at size1, pass through size2 at the midway point in the animation, and end at size3. You can have an arbitrary number of key frames and times for your animation, so you should be able to achieve the effect you desire

    EDIT (1/5/2010): Removed kCAAnimationPaced as a calculationMode, which would cause the key times to be ignored. Also, I forgot that frame was a derived property, so you need to animate something like the bounds size instead.

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

Sidebar

Related Questions

No related questions found

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.