开发者

Add a subview to a UIImageView that is the view outlet of a UIViewController in IB

开发者 https://www.devze.com 2023-02-09 00:33 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消