How do you override layerClass in swift

后端 未结 4 1775
醉话见心
醉话见心 2021-02-04 23:45

In Objective-C we use to do it like this

+ (Class)layerClass
{
    return [CAEAGLLayer class];
}

Obviously this won\'t work:

CA         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 00:31

    Adapted from Apple's ListerKit sample code:

    override class func layerClass() -> AnyClass {
        return CAEAGLLayer.self
    }
    

    Update for Swift 3:

    override class var layerClass: AnyClass {
        get {
            return CAGradientLayer.self
        }
    }
    

提交回复
热议问题