How to draw NSView on NSView?

I passed the NSView from the class and I need to add another NSView at some point. How to do it?

Thanks in advance.

+3
source share
2 answers

You can add a view to another view by sending an addSubview message, for example:

[MyView addSubview:MyOtherView];

Do not forget that you are responsible for displaying this presentation. Make sure you set its boundaries.

+3
source

You can position a new view when creating an instance using the initWithFrame: method, which will create the view and place it inside the supervisor (i.e. the one with which you will add your opinion with the addSubview message already mentioned :).

PS: View programming guide - your friend ..; -)

+1
source

Source: https://habr.com/ru/post/1770012/


All Articles