0

I am trying to render a vertical slider in interface builder however, when I try to set the value interface builder gives me a warning.

What am I doing wrong here?

@IBDesignable
class VerticalSlider: UISlider {

    @IBInspectable var setOrientation: Bool! {
        didSet {

            if setOrientation == true{

                self.transform = CGAffineTransformMakeRotation(CGFloat(-M_PI_2))

            }else {

                self.transform = CGAffineTransformIdentity

            }

        }
    }


}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
SNos
  • 3,430
  • 5
  • 42
  • 92

1 Answers1

0

Your @IBInspectable property setOrientation shouldn't be an implicitly unwrapped optional, just a non-optional boolean property.

If you change the declaration of setOrientation to a regular (non-optional) boolean with a default (initial) value, say false, you should no longer be prompted with warnings regarding your @IBInspectable.

@IBInspectable var setOrientation: Bool = false { ... }
dfrib
  • 70,367
  • 12
  • 127
  • 192