如何使用"getControlPoint(at idx: Int, values ptr: UnsafeMutablePointer<Float>!)" CAMediaTimingFunction
How to use "getControlPoint(at idx: Int, values ptr: UnsafeMutablePointer<Float>!)" CAMediaTimingFunction
我用这个在OC中使用这个功能
CAMediaTimingFunction *function = [CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionDefault];
//get control points
CGPoint controlPoint1, controlPoint2;
[function getControlPointAtIndex:1 values:(float *)&controlPoint1];
[function getControlPointAtIndex:2 values:(float *)&controlPoint2];
NSLog(@"%@, %@", NSStringFromCGPoint(controlPoint1), NSStringFromCGPoint(controlPoint2));
//{5.2386907149499368e-11, 7.9050503334599447e-323}, {0.0078125018189894035, 4.9406564584124654e-324}
但是怎么转换成swift3.1,我是这样操作的,但是出错了!
let timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
var point1 = Float(0.0), point2 = Float(0.0)
timingFunction.getControlPoint(at: 1, values: &point1)
timingFunction.getControlPoint(at: 2, values: &point2)
print("\(String(describing: point1)),\(String(describing: point2))")
// 0.25,0.25
如何解决?我需要一些帮助,拜托。注意代码打印。
let timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
var point1: [Float] = [0.0,0.0]
var point2: [Float] = [0.0,0.0]
timingFunction.getControlPoint(at: 1, values: &point1)
timingFunction.getControlPoint(at: 2, values: &point2)
print("\(String(describing: point1)),\(String(describing: point2))")
这是正确的转换。
我用这个在OC中使用这个功能
CAMediaTimingFunction *function = [CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionDefault];
//get control points
CGPoint controlPoint1, controlPoint2;
[function getControlPointAtIndex:1 values:(float *)&controlPoint1];
[function getControlPointAtIndex:2 values:(float *)&controlPoint2];
NSLog(@"%@, %@", NSStringFromCGPoint(controlPoint1), NSStringFromCGPoint(controlPoint2));
//{5.2386907149499368e-11, 7.9050503334599447e-323}, {0.0078125018189894035, 4.9406564584124654e-324}
但是怎么转换成swift3.1,我是这样操作的,但是出错了!
let timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
var point1 = Float(0.0), point2 = Float(0.0)
timingFunction.getControlPoint(at: 1, values: &point1)
timingFunction.getControlPoint(at: 2, values: &point2)
print("\(String(describing: point1)),\(String(describing: point2))")
// 0.25,0.25
如何解决?我需要一些帮助,拜托。注意代码打印。
let timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
var point1: [Float] = [0.0,0.0]
var point2: [Float] = [0.0,0.0]
timingFunction.getControlPoint(at: 1, values: &point1)
timingFunction.getControlPoint(at: 2, values: &point2)
print("\(String(describing: point1)),\(String(describing: point2))")
这是正确的转换。