在Swift 3中实现layoutAttributesClass()

Nas*_*ony 8 uicollectionview swift3 xcode8

我正在swift和xcode 8中编写自定义集合视图布局.我尝试使用以下函数实现自定义集合视图布局属性

override class func layoutAttributesClass() -> AnyClass {
    return CircularCollectionViewLayoutAttributes.self
  }
Run Code Online (Sandbox Code Playgroud)

但我得到错误'方法不会覆盖其超类中的任何方法'.任何帮助深表感谢.

ped*_*uan 28

你应该varSwift 3中使用而不是func :

override class var layoutAttributesClass: AnyClass {
    // ...
}
Run Code Online (Sandbox Code Playgroud)