Created
October 12, 2017 21:26
-
-
Save insidegui/f63dad60fd9a99cc23f976d0a1283286 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
// This only has to be called once in the application's lifetime | |
NSKeyedUnarchiver.setClass(CALayer.self, forClassName: "KFVectorLayer") | |
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorFeatureLayer") | |
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorAnimationLayer") | |
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorGradientFeatureLayer") | |
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorBitmapFeatureLayer") | |
let path = Bundle.main.path(forResource: "YOUR_FILE_HERE", ofType: "caar")! | |
let archive = NSKeyedUnarchiver.unarchiveObject(withFile: path) as! [String: Any] | |
let animLayer = archive["rootLayer"] as! CALayer | |
// You can now add animLayer as a sublayer of a view's layer, | |
// it's possible that the transform property will need to be changed | |
// to scale the animation layer to fit its superlayer, | |
// depending on the platform, you might need to flip the layer | |
// in the Y axis using another scale transform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment