У меня есть подпредставление со многими анимированными слоями CAShapeLayers, и это делает анимацию медленной.Кроме того, анимации должны выполняться последовательно, но я не знаю почему, они выполняются практически одновременно.Могу ли я что-то изменить, чтобы решить эти проблемы?(Я использую animateWithDuration).
Фрагмент:
for (id layer in self.layer.sublayers) {
...
[UIView animateWithDuration:1.5f
delay:0.0f
options: UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionTransitionCrossDissolve
animations:^{
subLayer.affineTransform = CGAffineTransformScale(subLayer.affineTransform, 1.5, 1.5);
[subLayer setZPosition:1000];
}
completion:^(BOOL finished) {
[UIView animateWithDuration:1.0f
delay:1.5f
options: UIViewAnimationOptionAllowUserInteraction
animations:^{ subLayer.affineTransform = CGAffineTransformIdentity;
}
completion:nil
];
}];
...
}
Я изменил способ анимации, но, тем не менее, он не плавный:
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(newCicle)
object:nil];
[queue addOperation:operation];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3f];
[UIView setAnimationCurve: UIViewAnimationCurveLinear];
int layerNumber = 1;
for (id layer in self.layer.sublayers) {
if ([layer isKindOfClass:[CAShapeLayer class]]) {
int k = layerNumber % SQHOR;
int i = ceil((float)layerNumber / (float)SQHOR);
CGColorRef color = nil;
if (changed[i][k]) {
if (matrix[i][k]) {
color = [[UIColor redColor] CGColor];
}
else {
color = [[UIColor whiteColor] CGColor];
}
CAShapeLayer *subLayer = (CAShapeLayer*)layer;
subLayer.fillColor = color;
}
layerNumber++;
}
}
[UIView commitAnimations];