Skip to content

Instantly share code, notes, and snippets.

@edudnyk
Last active July 28, 2019 17:09
Show Gist options
  • Save edudnyk/a7cd14432d0412e3bb767b520a3eb07a to your computer and use it in GitHub Desktop.
Save edudnyk/a7cd14432d0412e3bb767b520a3eb07a to your computer and use it in GitHub Desktop.
@objc @NSManaged open dynamic var attributedText : NSAttributedString?
open override func action(forKey event: String) -> CAAction? {
if event == keyPath(\LKLabelLayer.attributedText) {
/// Create and return our text interpolating `CAAction` instance here
}
return super.action(forKey:event)
}
open override class func needsDisplay(forKey key: String) -> Bool {
var result = super.needsDisplay(forKey: key)
result = result || key == keyPath(\LKLabelLayer.attributedText)
return result
}
func keyPath<Root, Key>(_ keyPath: KeyPath<Root, Key>)->String {
return NSExpression(forKeyPath: keyPath).keyPath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment