I'm subclassing `UIControl` to make a custom slider as an exercise in learning `UIKit`. The `setValue(value:)` method takes a float/double argument and animates the slider to that value. However, if the slider is not instantiated with an explicit frame, but instead sized using constraints, the `setValue()` method cannot be called without crashing as it requires the intrinsic width of the slider to determine where to animate the slider's thumb.

What would the proper strategy be to make sure an optional property (in this case, the width of `self`) becomes available before a method that has already been called is fully executed?

```
func addSlider() {

    slider.minimumValue = 0
    slider.maximumValue = 42
    slider.setValue(39)
    slider.addTarget(self, action: #selector(sliderAction(_:)), for: .valueChanged)
    slider.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(slider)
    slider.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    slider.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    slider.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -64).isActive = true

}

```

The problem is that `slider.setValue(39)` requires the slider's width to make the calculation.

```
override func draw(_ rect: CGRect) {

    superWidth = rect.width
    drawTrack()
    drawThumb()

}

...

func setValue(_ value: Float) {

    let thumbX = CGFloat(value / maximumValue!) * (superWidth - thumbDimension)

    UIView.animate(withDuration: 1, animations: { [weak self] in
        self?.thumbLayer.frame.origin.x = thumbX
    })

}

```