Skip to content

Instantly share code, notes, and snippets.

@mspvirajpatel
Created February 21, 2018 10:01
Show Gist options
  • Save mspvirajpatel/8ec4f97753417d5b2c33e7d4d2b61d55 to your computer and use it in GitHub Desktop.
Save mspvirajpatel/8ec4f97753417d5b2c33e7d4d2b61d55 to your computer and use it in GitHub Desktop.
How to create an IBInspectable of type enum
enum StatusShape:Int {
case Rectangle
case Triangle
case Circle
}
// Programmatically: use the enum
var shape:StatusShape = .Rectangle
// IB: use the adapter
@IBInspectable var shapeAdapter:Int {
get {
return self.shape.rawValue
}
set( shapeIndex) {
self.shape = StatusShape(rawValue: shapeIndex) ?? .Rectangle
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment