I followed this tutorial to build a custom slider that subclasses UIControl
. It works great when the control is programmatically inserted into the view, with the exact size, position, etc.
However, I wanted to use Storyboard to visually align the components of my view, so I added @IBDesignable
and @IBInspectable
to the custom slider class. Here's my problem:
setNeedsDisplay
in the init (coder: NSCoder)
method, but nothing works.Does anyone have any idea why this is happening and how I can fix it?
Calling setNeedsDisplay
in init
is obviously too early. Try viewWillAppear
and also try calling layoutSubviews
on the controller's view
.
But of course, the underlying error is a misconfiguration in the storyboard. (That would be difficult to debug via this platform).