Last active
July 29, 2019 21:13
-
-
Save edudnyk/da11b0826f68c37ed5d4043740ce3f59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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