title: iOS continuous fade-out and fade-in animation
body: <p>In <code>objective-c</code>, I want to add fade in and fade out animation to a <code>UIView</code>.  I want to do the fade-out and fade-in animation continuously.  To illustrate it, what effect I want to have is as following:</p>
  
  <p>fade out - fade in - fade out - fade in - ...</p>
  
  <p>What I'm trying is as following:</p>
  
  <pre><code>-(void)fadeOutIn:(UIView *)view duration:(NSTimeInterval)duration
  {
      static CGFloat alpha = 1.0;
      [UIView animateWithDuration:duration
                            delay:0.0
                          options: UIViewAnimationOptionRepeat| UIViewAnimationOptionCurveEaseInOut
                       animations:^{
                           alpha = abs((int)(alpha - 1.0));
                           view.alpha = alpha;
                       }
                       completion:^(BOOL finished){
                       }];
  }
  </code></pre>
  
  <p>I also tried following:</p>
  
  <pre><code>-(void)fadeOutIn:(UIView *)view duration:(NSTimeInterval)duration
  {
      [UIView animateWithDuration:duration
                            delay:0.0
                          options: UIViewAnimationOptionRepeat| UIViewAnimationOptionCurveEaseInOut
                       animations:^{
                           view.alpha = 0.0;
                       }
                       completion:^(BOOL finished){
  
                           [UIView animateWithDuration:duration
                                                 delay:0.0
                                               options: UIViewAnimationOptionRepeat|UIViewAnimationOptionCurveEaseInOut
                                            animations:^{
                                                view.alpha = 1.0;
                                            }
                                            completion:^(BOOL finished){
  
                                            }];
                       }];
  }
  </code></pre>
  
  <p>But the issue is they worked all the same, i.e., the <code>UIView</code> will fade out properly and <strong>SUDDENLY</strong> show up(not fade in), then fade out again...  </p>
  
  <p>Seems the fade in animation not work at all.  Does anybody know what's wrong of my code please?  Any suggestion will be highly appreciated.</p>