3

I have a class like this, and this IB doesn't show the property foo1 in inspection pane.

@IBDesignable
final class Foo: UIView {
    @IBInspectable var bar1 = CGFloat(0) 
}

What's wrong?

(Xcode 10.1)

eonil
  • 83,476
  • 81
  • 317
  • 516

1 Answers1

6

I don't know why, but explicit property type expression fixes the problem.

@IBDesignable
final class Foo: UIView {
    @IBInspectable var bar1 = CGFloat(0)   // No work. 
    @IBInspectable var bar2: CGFloat = 0   // Works!
}

I really don't know why one form doesn't work while the other works. I hope Apple to fix this ASAP.

eonil
  • 83,476
  • 81
  • 317
  • 516
  • A strange requirement that seems necessary at the moment, `@IBInspectable var bar = UIColor.red` will not work where as `@IBInspectable var bar: UIColor = .red` will. If anyone else is having issues I strongly recommend checking that you have denoted the type. – Carl Mar 12 '19 at 20:52
  • I'm following all of this. Still not working. `@IBInspectable var nestedStackAxis: NSLayoutConstraint.Axis = .vertical {` – ScottyBlades Jun 07 '21 at 03:16