Swift Pulse Animation
<p>i'm trying to make a pulse animation, i've found this:
<a href="https://stackoverflow.com/questions/8083138/ios-how-to-do-a-native-pulse-effect-animation-on-a-uibutton">How to do a native &quot;Pulse effect&quot; animation on a UIButton - iOS</a>
and it was useful, but i need something else,
so i have textfield, <code>UITextField</code> which has border,
when you focus on it i want the border to change color, but in specific way</p>
<p>I want it to start from center and then spread, I could not find the animation so i will try to demonstrate it via text: <code>B = Black</code>, <code>Y = Yellow</code>.</p>
<p>this is the border:</p>
<pre><code>BBBBBBB
</code></pre>
<p>border gets focused:</p>
<pre><code>BBBYBBB
BBYYYBB
BYYYYYB
YYYYYYY
</code></pre>
<p>animation is over, focus lost:</p>
<pre><code>BYYYYYB
BBYYYBB
BBBYBBB
BBBBBBB
</code></pre>
<p>my code looks something like this:</p>
<pre><code>let pulseAnimation = CABasicAnimation(keyPath: &quot;borderColor&quot;)
pulseAnimation.duration = 3
pulseAnimation.fromValue = UIColor.darkGrayColor().CGColor
pulseAnimation.toValue = UIColor.yellowColor().CGColor
pulseAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEasInEaseOut)
pulseAnimation.autoreverses = true
//pulseAnimation.repeatCount = FLT_MAX
x.layer.sublayers![0].addAnimation(pulseAnimation, forKey: nil)
</code></pre>
<p>it works but i need it to do something else</p>