Skip to content

Instantly share code, notes, and snippets.

@edudnyk
Last active July 29, 2019 21:13
Show Gist options
  • Save edudnyk/da11b0826f68c37ed5d4043740ce3f59 to your computer and use it in GitHub Desktop.
Save edudnyk/da11b0826f68c37ed5d4043740ce3f59 to your computer and use it in GitHub Desktop.
class LKTextDidChangeAction : CAAnimationGroup {
/// Here interpolation context gets stored
@objc var interpolatedAttributeStates : NSMutableDictionary!
var fromAttributedText : NSAttributedString?
var toAttributedText : NSAttributedString?
required override init() {
super.init()
}
required init(from text: NSAttributedString?) {
super.init()
fromAttributedText = text
interpolatedAttributeStates = type(of: self).stringAttributesDictionary
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func run(forKey event: String,
object anObject: Any,
arguments dict: [AnyHashable : Any]?) {
guard let textLayer = anObject as? LKLabelLayer,
event == keyPath(\LKLabelLayer.attributedText) else { return }
self.toAttributedText = textLayer.attributedText
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment