I have this circle (that fits inside the letter O which is currently not exactly a circle) and I want it to shrink and regrow, fading out and in. So I have it shrinking, and fading out, but when it does the animation, the CAShapeLayer moves to the top left of the screen and doesn't stay put in place (which is the objective). How do I accomplish this?
viewDidLoad {
CAShapeLayer *circle1 = [CAShapeLayer layer];
[circle1 setPath:[[UIBezierPath bezierPathWithOvalInRect:CGRectMake(74.93, 59.5, 31.52, 31.2)] CGPath]];
[circle1 setStrokeColor:[[UIColor colorWithRed:0.8 green:0.1 blue:0.2 alpha:1.0] CGColor]];
[circle1 setFillColor:[[UIColor colorWithRed:0.8 green:0.1 blue:0.2 alpha:1.0] CGColor]];
[[self.view layer] addSublayer:circle1];
CABasicAnimation* fadeAnim = [CABasicAnimation animationWithKeyPath:@"opacity"];
CABasicAnimation* shrinkAnim = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
fadeAnim.fromValue = [NSNumber numberWithFloat:1.0];
fadeAnim.toValue = [NSNumber numberWithFloat:0.0];
fadeAnim.duration = 1.25;
shrinkAnim.fromValue = [NSNumber numberWithFloat:1.0];
shrinkAnim.toValue = [NSNumber numberWithFloat:0.05];
shrinkAnim.duration = 1.25;
[circle1 addAnimation:fadeAnim forKey:@"opacity"];
[circle1 addAnimation:shrinkAnim forKey:@"transform.scale"];
circle1.opacity = 0.0;
}