How do I make an NSView move to the front of all NSViews

前端 未结 7 1067
既然无缘
既然无缘 2020-12-28 12:47

I have a super view, which has 2 subviews. These subviews are overlapped.

Whenever i choose a view from a menu, corresponding view should become the front view and h

7条回答
  •  死守一世寂寞
    2020-12-28 13:28

    Here's another way to accomplish this that's a bit more clear and succinct:

    [viewToBeMadeForemost removeFromSuperview];
    [self addSubview:viewToBeMadeForemost positioned:NSWindowAbove relativeTo:nil];
    

    Per the documentation for this method, when you use relativeTo:nil the view is added above (or below, with NSWindowBelow) all of its siblings.

提交回复
热议问题