title: AVFoundation focus animation using Core Animation
body: <p>So,I want to show a square box, a  I typical focus animation when a user taps on the screen. Here is what I have tried:</p>
  
  <pre><code>-(void)showFocusAnimation:(CGPoint)location{
  UIView *square = [[UIView alloc]initWithFrame:CGRectMake(location.x, location.y, 40, 40)];
  square.alpha=1.0;
  square.layer.borderColor = (__bridge CGColorRef)[UIColor colorWithRed:12.0/255.0 green:185.0/255.0 blue:249.0/255.0  alpha:1];
  square.layer.borderWidth = 2.0;
  [overlayView addSubview:square];
  
  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:.1];
  square.frame = CGRectMake(location.x, location.y, 90, 90);
  [UIView commitAnimations];
  
  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:.1];
  square.frame = CGRectMake(location.x, location.y, 40, 40);
  [UIView commitAnimations];
  
  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:.2];
  square.frame = CGRectMake(location.x, location.y, 90, 90);
  square.alpha = 0;
  [UIView commitAnimations];
  
  
  }  
  </code></pre>
  
  <p>I have a couple of problems that I cant seem to solve :</p>
  
  <ol>
  <li><p>I can't get my border to show up.</p></li>
  <li><p>Currently I am drawing a square starting from the point where the user tapped the screen. The point at which the user taps it, should actually be the center of the square.</p></li>
  <li><p>I can't seem to get the animation correct. What I am trying to do is, decrease the square size, increase it and then decrease it again and then the <code>alpha = 0</code>.</p></li>
  </ol>
  
  <p>I thought if I have 3 different separate animations maybe it will work, is not working. </p>