In Objective-C we use to do it like this
+ (Class)layerClass
{
return [CAEAGLLayer class];
}
Obviously this won\'t work:
CA
It can be written like this
import UIKit
class GradientView: UIView {
override final class var layerClass: AnyClass {
return CAGradientLayer.self
}
}
Bonus tip: Maybe you would like to have a type safe getter to the layer? Then you can write
import UIKit
class GradientView: UIView {
override final class var layerClass: AnyClass {
return CAGradientLayer.self
}
override var layer: CAGradientLayer {
return super.layer as! CAGradientLayer
}
}