我正在尝试为特定形状的路径更改设置动画。我可以通过用简单的.path [cgpath] setter替换此代码来手动更改而不用动画。但是,我想为美学的变化制作动画。
当执行此代码时,尽管日志表明动画已完成,但形状没有任何变化。
import { Component, OnInit } from '@angular/core'
import { Http } from '@angular/http'
@Component({
selector: 'site-config',
moduleId: module.id,
templateUrl: '/site-config.html'
})
export class SiteConfig implements OnInit {
items1: number[] = [1,2,3]
ngOnInit(): void {
}
public changedItem(item) {
//My Codes This Here
}
constructor(private http: Http) {
}
}
答案 0 :(得分:0)
for (CALayer *layer in self.view.layer.sublayers) {
if ([layer isKindOfClass:[CAShapeLayer class]]) {
CAShapeLayer *copy = (CAShapeLayer *)layer;
if ([sideChoice isEqualToString:@"datum"]) {
if ([copy.name isEqualToString:@"datumSideLayer"]) {
[CATransaction begin];
[CATransaction setCompletionBlock:^{
NSLog(@"Animation complete.");
}];
CABasicAnimation *morph = [CABasicAnimation animationWithKeyPath:@"path"];
morph.duration = 1;
morph.fromValue = (id) copy.path;
morph.toValue = (id) pathChange.CGPath;
[copy addAnimation:morph forKey:nil];
copy.path = [pathChange CGPath];
[CATransaction commit];
break;
}
} else if ([sideChoice isEqualToString:@"opposite"]) {
if ([copy.name isEqualToString:@"oppositeSideLayer"]) {
}
}
}
}
我没有正确设置fromValue,也没有指向CGPath。