2016-10-28 6 views
1

다음 애니메이션을 Swift3으로 변환하는 방법은 무엇입니까? 내가 현재 가지고있는NSValue valueWithCATransform3D : Swift3에서

CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 
scaleAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; 
scaleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(2.5, 2.5, 1)]; 

let circleEnlargeAnimation = CABasicAnimation(keyPath: "transform.scale") 
circleEnlargeAnimation.fromValue = CATransform3DIdentity 
circleEnlargeAnimation.toValue = CATransform3DMakeScale(10.0, 10.0, 1.0) 

입니다하지만 내 애니메이션 다음은 전체 애니메이션 코드입니다 ... 작동하지 않습니다 :

let shapeLayer = CAShapeLayer() 
    let center = CGPoint(x: sampleButton.bounds.width/2.0, y: sampleButton.bounds.height/2.0) 
    let radius = CGFloat(10.0) 

    let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: 0.0, endAngle: (CGFloat(360.0 * M_PI)/180.0), clockwise: true) 
    shapeLayer.path = path.cgPath 
    shapeLayer.fillColor = UIColor.white.cgColor 
    shapeLayer.strokeColor = UIColor.white.cgColor 
    shapeLayer.lineCap = kCALineCapRound 

    shapeLayer.frame = sampleButton.bounds 
    let circleEnlargeAnimation = CABasicAnimation(keyPath: "transform.scale") 
    circleEnlargeAnimation.fromValue = CATransform3DIdentity 
    circleEnlargeAnimation.toValue = CATransform3DMakeScale(10.0, 10.0, 1.0) 
    circleEnlargeAnimation.duration = 1.0 
    shapeLayer.add(circleEnlargeAnimation, forKey: nil) 

    sampleButton.layer.addSublayer(shapeLayer) 

그것은 만 원을 표시하지만입니다 애니메이션 적용 안 함 ...

답변

3

transform.scale에 스칼라 숫자 값 o r transform은 행렬 값을가집니다. 사용 가능한 키의 전체 목록은 Key Value Coding Extensions in Core Animation Programming Guide을 참조하십시오.

NSValue(caTransform3D:CATransform3DMakeScale(10.0, 10.0, 1.0)) 
:

당신과 함께 예를 들어 행렬의 값을 만들 수 있습니다