0
我正在努力爲CAShape圖層設置動畫,但無法正確繪製它。我有一個圖層。在UIView子類我創建的CALayer如下 -在CAShapeLayer中展開放置動畫
CAShapeLayer *shape1 = [CAShapeLayer layer];
shape1.fillColor = [[UIColor clearColor] CGColor];
shape1.strokeColor = [[UIColor purpleColor] CGColor];
CGRect frame1 = CGRectMake(13, 13, self.bounds.size.width - 26, self.bounds.size.height - 26);
shape1.frame = frame1;
shape1.position = CGPointMake(0,0);
shape1.anchorPoint = CGPointMake(self.tableContainerView.frame.size.width/2.0,
self.tableContainerView.frame.size.height/2.0);
shape1.path = [self pathForFrame:frame1];
shape1.strokeEnd = 0.0f;
shape1.lineWidth = 1.0;
[self.layer addSublayer:shape1];
我想,使其達到一定的地方看起來比初始稍大,同時保持中心製作動畫,這將創造擴大地方影響。我的縮放動畫代碼是 -
CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
//animation2.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
animation2.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1, 1.1, 1.1)];
animation2.repeatCount = 1;
animation2.removedOnCompletion = NO;
animation2.fillMode = kCAFillModeForwards;
animation2.duration = 10;
animation2.beginTime = CACurrentMediaTime() + 4;
[shape1 addAnimation:animation2 forKey:nil];
任何幫助表示讚賞。提前致謝。
中序,使這個動畫作品,形狀圖層添加到一個UIView,而不是做[shape1 addAnimation:animation2 forKey:@ 「transform.scale」];嘗試做[view.layer addAnimation:animation2 forKey:@「transform.scale」]; –
已編輯的問題。已經添加了形狀來查看(self.layer正在這樣做)。請分析收益。 – Avi