나는 애니메이션을 적용하는 많은 CAShapeLayers가있는 하위 뷰가 있으며 이로 인해 애니메이션이 느려집니다. 그 외에도 애니메이션은 순차적으로 실행되어야하지만, 왜 그런지는 거의 모릅니다. 동시에 거의 동시에 실행됩니다. 이 문제를 해결하기 위해 내가 바꿀 수있는 것이 있습니까? (나는 animateWithDuration을 사용하고있다.)iOS - 애니메이션을 느리게 만드는 다중 레이어
니펫 :
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];
당신이 몇 가지 코드 조각을 붙여 넣을 수 있습니까? :) – Kjuly
위에 게시 : D –