0

In Xcode on the StoryBoard I built a complex UI element consisting of many sub-views.

I encapsulated it all into a UIView subclass but each element has to be built out on the storyboard wherever it is used.

Is there a way to build it in such a way that all a developer would need to do to use it is to add a UIView of the appropriate sub-class and not need to layout all of the subviews? Similar to how we do not need to interact with the underlying structure of buttons or labels.

Cœur
  • 37,241
  • 25
  • 195
  • 267
CSjunkie
  • 535
  • 2
  • 8
  • 28

1 Answers1

0

This is possible, but it requires a bit of a workaround. It basically requires you to create a UIView subclass, which loads all it's subviews from a separate nib file

This question has the answers for you.

Rengers
  • 14,911
  • 1
  • 36
  • 54
  • Thanks! I was able to accomplish this by creating a xib of what I wanted and then subclassing UIView that read from the xib. I also subclassed a UIView that only contains the UIView that reads the xib and am able to load the xib from the container without the viewController needing to do anything. – CSjunkie May 03 '19 at 15:10