How can I addSubview to UIButton in Interface Builder

后端 未结 4 1712
轻奢々
轻奢々 2021-02-18 22:57

Like I said, I add a UIButton in Interface Builder, I want add a UILabel、UIImageView as the button\'s subviews, but I can\'t add any object on it in IB. IS anybody know how to d

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-18 23:45

    I normally achieve this by

    1. Create a new UIView in Interface Builder and set it to be the same size and location that you want your button to have
    2. Add your subviews to that UIView
    3. Set the UIView's class to UIButton in the Indentity Inspector

    Your UIView now works exactly like a UIButton

提交回复
热议问题