Add a subview to a UIImageView that is the view outlet of a UIViewController in IB
I have a UIViewController object in a .xib file. I add a UIImageView to it, and then try to add a button as a subview of the UIImageView. It instead replaces the UIImageView开发者_开发问答. It works fine if both are subviews of a UIView. What gives? I thought this would work since UIImageView is a subclass of UIView?
Only Apple knows.
However, look at here for a workaround:
Apple Interface Builder: adding subview to UIImageView
A UIImageView
is it's own object and a UIButton
is its own object. A UIImageView
is an outlet placeholder for an image. If you're trying to add a background image to a button you can use the background image property or if you'd like the background to span beyond the bounds of the button you can drop a UIView
onto IB and style that using code or subclassing UIImageView
.
精彩评论