2

Is it not possible to add a subview to a UIButton via Storyboard? This answer suggests it is possible in code, but how do you do it via Storyboard? Dragging a UIView to become a child of a UIButton isn't working.

Aware of simple workarounds like creating a parent UIView to hold the UIButton and subviews, but this question focuses on whether it's possible to add subviews to a UIButton inside of Storyboard.

Community
  • 1
  • 1
Crashalot
  • 33,605
  • 61
  • 269
  • 439

1 Answers1

5

You cannot add subviews to UIButton in Interface Builder, use UIView as container, then add UIButton and whatever you want to it. Note, eg. you can place a UILabel on top of the button and if you do not set userInteractionEnabled = YES for that label, your button will still response to touch events. Also refer to this answer.

Community
  • 1
  • 1
schmidt9
  • 4,436
  • 1
  • 26
  • 32