2011-03-02 95 views
0

我有一个图形视图,我想重叠一些按钮。当我使用按钮创建一个笔尖并在添加图形后将其添加为子视图时,它只是在白色屏幕上显示按钮。如何在iOS上堆叠子视图?

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

那么GraphButtonView会保存按钮?那“GraphButton”将会在“GraphView”中?如果是这样,您可以简单地添加GraphButtonViewController.view作为图形视图的子视图 [graphViewController.view addSubview:graphButtonViewController.view]; – 2011-03-02 00:29:47

回答

1

您是否尝试让您的GraphButtonView xib具有透明背景(它是(主)视图?

+0

是的,我刚刚意识到这是问题,谢谢。一个问题是按钮视图阻止了图形上的功能。是通过使笔尖非常小(仅在按钮周围)来解决这个问题的方法吗?或者我应该尝试以编程方式添加UIButtons或其他东西。 – 2011-03-02 00:32:58

+0

我通常以编程方式添加重叠按钮。这样,如果我调整图形大小,我可以将按钮移动到合适的位置。 – hotpaw2 2011-03-02 00:34:25

+0

您可以为按钮制作任何尺寸的视图容器。如果你喜欢在IB工作,那么确保XIB的主视图有状态栏 - 无。您现在可以重新调整视图的大小。 – 2011-03-02 01:25:38