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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:06:35+00:00 2026-05-27T17:06:35+00:00

I have an animation that bounces a view slightly along the x axis. The

  • 0

I have an animation that bounces a view slightly along the x axis. The problem is that is is using the old animation mechanism and as the documentation states use of block based animations are recommended for iOS4+. I’m wondering how I can turn this simple animation into a block based animation:

[UIView beginAnimations:@"bounce" context:nil];
[UIView setAnimationRepeatCount:2];
[UIView setAnimationRepeatAutoreverses:YES];
self.view.center = CGPointMake(self.view.center.x + 10, self.view.center.y);
[UIView commitAnimations];

Also I want the view to return to its starting position after the animation ends, the method above bounces the view and increments its x value by 10 pixels.

Thanks for any help.

  • 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-27T17:06:36+00:00Added an answer on May 27, 2026 at 5:06 pm

    Block-base animation’s format is like this:

    [UIView animateWithDuration:<#(NSTimeInterval)#>
                          delay:<#(NSTimeInterval)#>
                        options:<#(UIViewAnimationOptions)#>
                     animations:<#^(void)animations#>
                     completion:<#^(BOOL finished)completion#>];
    

    And the code below bounces the view twice and go back to origin position, maybe there exists a better way:

    [UIView animateWithDuration:0.2f
                          delay:0.0f
                        options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         self.view.center = CGPointMake(self.view.center.x + 10, self.view.center.y);
                     }
                     completion:^(BOOL finished) {
                         self.view.center = CGPointMake(self.view.center.x - 10, self.view.center.y);
                         [UIView animateWithDuration:0.2f
                                               delay:0.0f
                                             options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionCurveEaseInOut
                                          animations:^{
                                              self.view.center = CGPointMake(self.view.center.x + 10, self.view.center.y);
                                          }
                                          completion:^(BOOL finished) {
                                              self.view.center = CGPointMake(self.view.center.x - 10, self.view.center.y);
                                          }];
                     }];
    

    And this one is similar, but go back to origin position not smoothly.

    [UIView animateWithDuration:0.2f
                          delay:0.0f
                        options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         self.view.center = CGPointMake(self.view.center.x + 10, self.view.center.y);
                         self.view.center = CGPointMake(self.view.center.x - 10, self.view.center.y);
                     }
                     completion:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an animation that is ran on a timer along with some other
I have some animation that does some rotation using beginAnimations. I want to hide
So I have an animation that is being created by having a bunch of
I have this CSS3 animation that works in Chrome .circle-label-rotate { -webkit-animation-name: rotateThis; -webkit-animation-duration:.5s;
I have created a jQuery animation that can be seen by clicking the Preview
What I have right now is an animation that starts when I press space:
I have what I thought was a relatively easy Ajax/animation that I'm adding to
I have an animation on a partially hidden div container that will execute when
I have a page that has a gif animation in a hidden div. Upon
I have an AnimatedSprite that after it finishes the animation I want to reverse

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.