我正在尝试将一些在Objective-C中工作的代码转换为
Swift.我遇到的问题是needsDisplayForKey / actionForKey没有以相同的方式调用.据我所知,自定义键值未正确传递.这是我调试它时得到的结果:
原文链接:https://www.f2er.com/swift/319455.html默认值:
(String!) event = { core = { _baseAddress = Builtin.RawPointer = 0x00feee51 "onOrderIn" _countAndFlags = 1073741833 _owner = Some { Some = (instance_type = Builtin.RawPointer = 0x01026348 @"onOrderIn") } } }
自定义值(传入空字符串):
(String!) event = { core = { _baseAddress = Builtin.RawPointer = 0x0b418f79 _countAndFlags = 1073741833 _owner = Some { Some = (instance_type = Builtin.RawPointer = 0x0b418f70 -> 0x006e38f0 (void *)0x006e38c8: __NSCFString) } } }
我不确定相关代码是什么.我只想问 – 有没有其他人能够在Swift中定义自定义隐式动画?从Objective C移开时有什么我需要记住的吗?
override class func needsDisplayForKey(key: String!) -> Bool{ if key == "angleFrom" || key == "angleTo" { return true; } return super.needsDisplayForKey(key) } override func actionForKey(event: String!) -> CAAction!{ if event == "angleFrom" || event == "angleTo" { return self.makeAnimationForKey(event) } return super.actionForKey(event) }