0

I am trying to animate UIViews that are added as a subView to scrollView.This works fine without autolayout , however with autolayout it doesn't seem to work.

Here is what I am doing :

            [UIView animateWithDuration:1.0 animations:^(void){

                [self.commenView setFrame:({
                    CGRect frame = self.commenView.frame;
                    frame.origin.y  = 335;
                    frame;

                })];

                [self.addDeleteCommentView setFrame:({
                    CGRect frame = self.addDeleteCommentView.frame;
                    frame.origin.y  = 405;
                    frame;

                })];

            }];
iCodes
  • 1,382
  • 3
  • 21
  • 47
  • If you are using autolayout, rather than animating the geometry through frame or bounds, use constraints to resize and position. That is infact easy and preferred way of doing with autolayout. – Sandeep May 07 '14 at 09:11
  • How would I do it in this case?can you give an example? – iCodes May 07 '14 at 09:13
  • http://stackoverflow.com/questions/13296232/ios-how-does-one-animate-to-new-autolayout-constraint-height – Sandeep May 07 '14 at 09:15
  • Let me explain to you a bit further, if you want to so animate the origin y position of the view. Then, create a top constraint in interface builder and create an IBOutlet out of it. Then when you want to animate say suppose move it down below by 20, you would do it like, [UIView animateWithDuration:2.0 animations:^{ self.myTopConstraint.constant = 20; [self.view setNeedsUpdateConstraints]; }]; – Sandeep May 07 '14 at 09:18
  • ohk...actually in my case, I have these views created in code.So cannot really use interface builder? – iCodes May 07 '14 at 10:05

0 Answers0