Using UIView animateWithDuration: delay: Xcode

I'm trying to use

[UIView animateWithDuration:1 delay:2 options:UIViewAnimationOptionCurveEaseIn animations:^{
} completion:^ (BOOL completed) {}         ];

however no matter what number I put for the delay, there is no delay.
I'm trying to make a series of buttons fade out one after another when another button is touched. Therefore, I use a series of UIView animations with different delay times, but they all appear at the same time, no matter what time delay I enter. Does anyone have any suggestions?

+4
source share
3 answers

First of all, the values animateWithDurationand delayare the values and should be like and float1.02.0

:, ViewDidLoad,

-, , , ,

performSelector:withObject:afterDelay

- delay 0 UIView completion animateWithDuration

 [UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
                 animations:^(void) {
        //Leave it empty
                 }
                 completion:^(BOOL finished){

// Your code goes here
   [UIView animateWithDuration:1.0 delay:0.0 options:
   UIViewAnimationOptionCurveEaseIn animations:^{
        } completion:^ (BOOL completed) {}];
    }];

PS: , , , , , , .

. , , :

[UIView animateWithDuration:1.0
                      delay:2.0
                    options: UIViewAnimationOptionTransitionCrossDissolve
                 animations:nil
                 completion:^{
                     lbl.text =  @"My text" ;
}];

backgroundColor UIView. backgroundColor layer:

[[controller layer] setBackgroundColor:[[UIColor anyColor] CGColor]];
+16

viewWillAppear.

- (void)viewWillAppear:(BOOL)animated {
    [UIView animateWithDuration:1.0
                          delay:2.0
                        options:UIViewAnimationOptionTransitionCrossDissolve
                     animations:^{
                         //yourAnimation
                     } completion:^(BOOL finished){
                         NSLog(@"Animation is finished");
                     }];
}
+2

, , : , . 0, . delay: ( ) . 0, .

- - , &

, , ViewDidAppear/viewWillapear.

Use function like this & set your UI Element properties like this:
 [UIView animateWithDuration:0.6
                          delay:0.3
                        options: UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         [self.view layoutIfNeeded];
                         [yourviews setTintColor:[UIColor whiteColor]];
                         self.view.backgroundColor = [UIColor greenColor];
                     }
                     completion:^(BOOL finished){

                         // You next action to perform after completion;
                     }];
}

, , .

+1
source

Source: https://habr.com/ru/post/1525176/


All Articles