title: Core Animation animation lag
body: <p>I am trying to fade in a few views in using Core Animation. Everything is alright until the 4th or 5th view is faded in. The animation stops and a few seconds later the rest of the views is just put on screen (no animation is happening). I tested it on an 3rd generation iPad, so it can't be an issue of outdated hardware. Code:</p>
  
  <p><strong>viewDidLoad</strong></p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
      self.subViews = self.view.subviews;
  
      for (UIView *view in self.subViews) {
          view.backgroundColor = [UIColor clearColor];
          PhotoFrame *photoFrame = [[PhotoFrame alloc] init];
          photoFrame.photo.image = [UIImage imageNamed:[NSString stringWithFormat:@"test%d.jpg", arc4random() % 6 + 1]];
          [view addSubview:photoFrame];
          view.layer.opacity = 0;
      }
  }
  </code></pre>
  
  <p><strong>viewDidAppear</strong></p>
  
  <pre><code>- (void)viewDidAppear:(BOOL)animated {
      [super viewDidAppear:animated];
      [self startAnimations];
  }
  </code></pre>
  
  <p><strong>startAnimations</strong></p>
  
  <pre><code>- (void)startAnimations {
      int count = 1;
      for (UIView *view in self.subViews) {
          CALayer *animationLayer = view.layer;
  
          CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
          animation.fromValue = @0.0;
          animation.toValue = @1.0;
          animation.duration = 0.3;
          animation.beginTime = CACurrentMediaTime() + count * 0.3;
          animation.removedOnCompletion = NO;
          animation.fillMode = kCAFillModeForwards;
  
          [animationLayer addAnimation:animation forKey:@"opacityAnimation"];
          count++;
      }
  }
  </code></pre>
  
  <p>I hope that anyone can help me.</p>