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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:22:18+00:00 2026-05-24T10:22:18+00:00

I have this code: when image change alpha from 0.00 to 1.00 it is

  • 0

I have this code:

when image change alpha from 0.00 to 1.00 it is imediately and not in 3 seconds, why?

- (void) startAnimation{

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:3];
[successView setAlpha:1.00];
[UIView commitAnimations];


[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:3];
[successView setAlpha:0.00];
[UIView commitAnimations];}
  • 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-24T10:22:18+00:00Added an answer on May 24, 2026 at 10:22 am

    Both animations are run in the same run cycle (that’s how UIView animations work—all animations in one run cycle are “concatenated.” You’ll need to use

    [UIView setAnimationDelay:3.0];
    

    On the second animation.


    Example Code
    There are two ways to do this—using the standard begin/commit animations, or using the blocks method. This example uses the begin/commit animations code, which is what you have. The issue is because the animations are being concatenated, and without going into CA, the standard animation behavior is for one to be “forced” to end before the other runs. It has to do with run loops; Building Animation-Driven Interfaces from WWDC 2010 goes into depth about this. But the code to do what you want looks like this:

    - (void)fadeOut {
        [UIView beginAnimations:@"Animation2" context:NULL];
        [UIView setAnimationDuration:3];
        [self.testView setAlpha:0.00];
        [UIView commitAnimations];
    }
    - (IBAction)animate {
        [UIView beginAnimations:@"Animation1" context:NULL];
        [UIView setAnimationDuration:3];
        [self.testView setAlpha:1.00];
        [UIView commitAnimations];
    
        [self performSelector:@selector(fadeOut) withObject:nil afterDelay:3.0];
    }
    

    You have to force it to break up the run loop, basically. The key thing to remember is that animations are not executed sequentially, as you might expect code to be.

    The blocks-based code looks like this. Note that I’m using the autorepeat option, which automatically repeats the animation. Note though that in the animation, you are setting a property, so by default after the animation completes the view will go back to being visible. Therefore, you have the set the property again to zero in the completion block.

    - (IBAction)animate {
        [UIView transitionWithView:self.testView duration:3.0 options:UIViewAnimationOptionAutoreverse animations:^{self.testView.alpha = 1.0;} completion:^(BOOL finished) {self.testView.alpha = 0.0;}];
    }
    

    Hopefully this helps!

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

Sidebar

Related Questions

i have create this code for my button but the image doesen't change why?
I have this code which should create a splash image with either no animation
I have this code, but i cant make it work: images = Image.find_by_sql('PREPARE stmt
Problem Hello all! I have this code which takes my jpg image loops through
I have this piece of code: <table style=background-image: url(path/to_image.png)> And when I load it
I have written this code in C# for WP7 : public void btn_handler(object sender,
i have implemented a code that fetch single image from 1000+ images. The image
I have this code, where lineaRedToday is an UIImageView: - (void)viewDidLoad { [super viewDidLoad];
I have this code to center an image between two horizontal lines. CSS: .line-scale-left
I have this code, how can I allow it to accept all typical image

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.