开发者

How to draw a NSView on a NSView?

开发者 https://www.devze.com 2023-01-20 03:46 出处:网络
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?

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.. ;-)

0

精彩评论

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