Reputation: 31
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?
Thanks in advance.
Upvotes: 3
Views: 1316
Reputation: 6638
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.. ;-)
Upvotes: 1
Reputation: 699
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.
Upvotes: 3