Skip to content

Instantly share code, notes, and snippets.

@MP0w
Created April 14, 2016 13:21
Show Gist options
  • Save MP0w/df33346756b48902d6738180d90d999b to your computer and use it in GitHub Desktop.
Save MP0w/df33346756b48902d6738180d90d999b to your computer and use it in GitHub Desktop.
Generic view with custom layer class
class CustomLayerView<T: CALayer>: UIView {
var customLayer: T {
get {
return self.layer as! T
}
}
override class func layerClass() -> AnyClass {
return T.self
}
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment