0

I have an animation of UIView using the following block based animation method. The animation basically resize a view width from 300 pixel to 0 in 60 seconds. But the problem is view is resized to 0 width even before 60 seconds(around 55-56 seconds) but the completion block is called in right time (after 60 seconds). Here is the code-

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 150, 300, 40)];
view.backgroundColor = [UIColor redColor];
[self.window.rootViewController.view addSubview:view];

NSLog(@"start");
[UIView animateWithDuration:60.0f
                 animations:^{
                     view.frame = CGRectMake(10, 150, 0, 40);

                 } completion:^(BOOL finished) {
                     NSLog(@"Completion");
                 }
 ];

Can someone please say the reason for this?

russell
  • 3,668
  • 9
  • 43
  • 56
  • I can see this. When it reaches to 0, view shows nothing. – russell Sep 26 '14 at 10:30
  • I checked with console log + macbook timer, i noticed 'completion' log is called in 60 seconds which is correct, but view reaches to 0 width 4-5 seconds before that. – russell Sep 26 '14 at 10:55
  • A shot in the dark here, could it be that part of your view is partly 'hidden' under another view or simply cut off by a superview and let you perceive it as having 0 width? – F1ank3r Sep 26 '14 at 11:15
  • @F1ank3r, no there is no other view. – russell Sep 26 '14 at 11:25
  • @Unheilig, No, I didn't subtract time to get animation time, I used console log print time provided by apple (left side of console log). Moreover, i added two other view with NSTimer(60 seconds) to check how they reduce according to time. They work correctly, moreover animation completion block trigger at right time , after 60 seconds,so i can guarantee time is accurate. About your 2nd point, it's a 300 point frame, each seconds should be reduced by average 5 point, even with UIAnimation which works in little bit differently in update calculation, 4-5 seconds means 20-25 point is huge. – russell Sep 26 '14 at 11:32
  • So there is no reason not to see it. If you run the code you will get same thing i think. – russell Sep 26 '14 at 11:33

0 Answers0