Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

swift enum nib

// There is no way to do this. But there is a little workaround.

// Swift 5:
public enum Size: String {
  case small = "small"
  case medium = "medium"
  case large = "large"
}

class SizeView: UIView {
  private var size: Size = .large

  @IBInspectable 
  public var sizeName: String = "large" {
    didSet {
      guard self.sizeName != oldValue else { return }
      self.size = Size(rawValue: self.sizeName)
    }
  }
}
Source by www.hackingwithswift.com #
 
PREVIOUS NEXT
Tagged: #swift #enum #nib
ADD COMMENT
Topic
Name
6+7 =