Iphone 如何在iOS上堆叠子视图?

Iphone 如何在iOS上堆叠子视图?,iphone,ios,Iphone,Ios,我有一个图形视图,我想覆盖一些按钮。当我创建一个带有按钮的笔尖,并在添加图形后将其添加为子视图时,它只是在白色屏幕上显示按钮 GraphViewController *graphViewController = [[GraphViewController alloc] init]; [self.view addSubview:graphViewController.view]; GraphButtonViewController *graphButtonViewController = [[Gr

我有一个图形视图,我想覆盖一些按钮。当我创建一个带有按钮的笔尖,并在添加图形后将其添加为子视图时,它只是在白色屏幕上显示按钮

GraphViewController *graphViewController = [[GraphViewController alloc] init];
[self.view addSubview:graphViewController.view];
GraphButtonViewController *graphButtonViewController = [[GraphButtonViewController alloc] initWithNibName:@"GraphButtonView" bundle:nil];
[self.view addSubview:graphButtonViewController.view];

您是否尝试使GraphButtonView xib的(主)视图有一个透明的背景?

这样GraphButtonView可以容纳按钮?“GraphButton”会在“GraphView”中吗?如果是这样,只需将GraphButtonViewController.view添加为图形视图的子视图[graphViewController.view addSubview:GraphButtonViewController.view];是的,我刚意识到这就是问题所在,谢谢。一个问题是按钮视图阻止了图形上的功能。解决这个问题的方法是将笔尖变小(只在按钮周围)?或者我应该尝试以编程方式添加UIButtons或其他什么。我通常以编程方式添加叠加按钮。这样,如果我调整图形的大小,我可以移动按钮以适应。您可以为按钮创建任意尺寸的视图容器。如果您喜欢在IB中工作,那么请确保XIB的主视图具有状态栏-无。现在可以重新调整视图的大小。