简体   繁体   中英

Make UIView subview as default UIView for UIViewController with Storyboard

I have a multi-viewcontroller app.

The main view of the main VC is subclassed so I can use Core Graphics animations. It's called "animations" class.

On the storyboard, I add a UIView called "MainArea" as a subview of the "animations". I have a VC called "MainAreaVC". As you know it has a property of "view". How can I make the "MainArea" subview the default UIView of my "MainAreaVC"?

The other option is to just make the "MainArea" view a property of my "MainAreaVC" and use this. I just don't want the "MainAreaVC"'s default "view" property just hanging out doing nothing.

The view in a UIViewController is the bottom view: it is always the one at the root of the tree hierarchy, and appears behind everything else, possibly clipping subviews.

You can change the view Class , but no matter what you do, by design it must be at the root. If, somehow, you managed to point to one of your subviews, that subview would in essence become the root.

Comment:

You do not have to add a view of type animations containing another view of type mainArea . You can have 'MainArea inherit from animations , and drag such MainArea` in the storyboard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM