Swift 中的 AHEasing 运行 吗?
Does AHEasing run in Swift?
我正在尝试在我的 Swift 项目中使用 AHEasing。我已经通过 cocoapods 安装了它,并将这一行包含在我的桥接中 header:
#import <AHEasing/CAKeyframeAnimation+AHEasing.h>
我可以访问 CAKeyframeAnimation+AHEasing.h 中的函数,但是当我尝试
var alphaAnimation = CAKeyframeAnimation.animationWithKeyPath("alpha", function: QuadraticEaseInOut, fromValue: 1.0, toValue: 0.0)
我收到错误
Cannot invoke 'animationWithKeyPath' with an argument list of type '(String, function: (Double) -> Double, fromValue: Double, toValue: Double)'
经过一番挖掘,我确认 QuadraticEaseInOut 确实被转换为 (Double) -> Double 闭包,而该参数的类型 AHEasingFunction 被转换为 CFunctionPointer<((Double) ->双)>.
有没有办法在这两种类型之间进行转换?有人在 Swift 中成功使用过 AHEasing 吗?还有其他我没有看到的解决方法吗?
我听说有人报告说这是 Swift 1.2 的问题,在 Swift 2 中不再是问题。
无论如何,我只是通过在 Swift.
中完全实现我需要的 AHEasing 功能来解决这个问题
我正在尝试在我的 Swift 项目中使用 AHEasing。我已经通过 cocoapods 安装了它,并将这一行包含在我的桥接中 header:
#import <AHEasing/CAKeyframeAnimation+AHEasing.h>
我可以访问 CAKeyframeAnimation+AHEasing.h 中的函数,但是当我尝试
var alphaAnimation = CAKeyframeAnimation.animationWithKeyPath("alpha", function: QuadraticEaseInOut, fromValue: 1.0, toValue: 0.0)
我收到错误
Cannot invoke 'animationWithKeyPath' with an argument list of type '(String, function: (Double) -> Double, fromValue: Double, toValue: Double)'
经过一番挖掘,我确认 QuadraticEaseInOut 确实被转换为 (Double) -> Double 闭包,而该参数的类型 AHEasingFunction 被转换为 CFunctionPointer<((Double) ->双)>.
有没有办法在这两种类型之间进行转换?有人在 Swift 中成功使用过 AHEasing 吗?还有其他我没有看到的解决方法吗?
我听说有人报告说这是 Swift 1.2 的问题,在 Swift 2 中不再是问题。
无论如何,我只是通过在 Swift.
中完全实现我需要的 AHEasing 功能来解决这个问题