How to draw a NSView on a NSView?
I am passed a NSView from a class and I need to add on another NSView at a certain point. How do I do that?
Tha开发者_运维问答nks in advance.
You can add a view to another view by sending the addSubview message, like this:
[MyView addSubview:MyOtherView];
Don't forget though, you are responsible for how that view displays. Make sure you set its bounds.
You can position the new view when instantiating it using the initWithFrame: method that'll create the view and position it within the superview (i.e. the one you'll add your view to with the already mentioned addSubview: message).
PS: The View Programming Guide - is your friend.. ;-)
精彩评论