I have been struggling with an animation effect on iOS7 (8, 9 it works fine) that involves contracting a rounded rect to become a circle. To get an effect like this.
But i am getting some distortion when trying to contract the circle on iOS7.
My view controller is pretty simple
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CAShapeLayer *layer = [CAShapeLayer layer];
layer.fillColor = [UIColor blackColor].CGColor;
layer.frame = CGRectMake(100, 100, 100, 100);
layer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 100, 50) cornerRadius:25].CGPath;
self.myLayer = layer;
[self.view.layer addSublayer:layer];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"path"];
animation.values = @[
(id)[UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 100, 50) cornerRadius:25].CGPath,
(id)[UIBezierPath bezierPathWithRoundedRect:CGRectMake(5, 0, 90, 50) cornerRadius:25].CGPath,
(id)[UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 0, 80, 50) cornerRadius:25].CGPath,
(id)[UIBezierPath bezierPathWithRoundedRect:CGRectMake(15, 0, 70, 50) cornerRadius:25].CGPath,
(id)[UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 0, 60, 50) cornerRadius:25].CGPath,
(id)[UIBezierPath bezierPathWithRoundedRect:CGRectMake(25, 0, 50, 50) cornerRadius:25].CGPath,
];
animation.keyTimes = @[@(0),
@(0.18),
@(0.36),
@(0.54),
@(0.72),
@(1),
];
animation.duration = 10;
animation.fillMode = kCAFillModeForwards;
[self.myLayer addAnimation:animation forKey:nil];
self.myLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(25, 0, 50, 50) cornerRadius:25].CGPath;
}