SeanChense
SeanChense

Reputation: 846

Move UIView with animation and it rolls back by itself

I have a UIView drawn in Storyboard which holds some buttons and which is called viewHolder.

I get a higher position rectForAnimationBefore

and a lower position rectForAnimationAfter

[UIView animateWithDuration:1.0
                              delay:0.0
                            options:UIViewAnimationOptionCurveEaseInOut
                         animations:nil completion:^(BOOL finish){
                             [self.viewHolder setFrame:rectForAnimationAfter];
                         }];

when this is excuted,the viewHolder do move down.After a second,it comes up as nothing was done.

I want to moveDown,but don't want moveUp Automatically.

Because autolayout in Storyboard? By the way ,how to move it smoothly?

Thank you guys.

UPDATE:

[UIView animateWithDuration:1.0
                              delay:0.0
                            options:UIViewAnimationOptionCurveEaseInOut
                         animations:^{
                             [self.viewHolder setFrame:rectForAnimationAfter];
                         }
                         completion:^(BOOL finish){

                         }];

when I change code like this ,I can't move it down .

Here is my solution

unlock the autolayout!!!

Upvotes: 1

Views: 595

Answers (1)

Hussaan S
Hussaan S

Reputation: 281

First thing your animation block is nil. Here you should move your view down. At completion you are setting back you view without using any animation. For smoothness you need to move back your view animatedly.

Upvotes: 1

Related Questions