我有基于导航控制器的应用程序,一个视图控制器以横向模式呈现模态图。然后我添加带有完成按钮的工具栏以关闭图形 vc 并返回导航和纵向模式。
我不知道如何将工具栏放置在图形视图控制器的顶部,并在工具栏的底部使用正确的阴影。到目前为止,我有这段代码可以将工具栏添加到底部位置,该位置在工具栏顶部有默认阴影。是否允许在屏幕顶部有工具栏?由于强制方向旋转,我不能将导航控制器与图形 vc 一起使用。平台仅限 iOS7 和 iPhone。谢谢。
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.size.width - 44.0, self.view.bounds.size.height, 44.0)];
UIBarButtonItem *flexibleSpaceButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *doneButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
toolbar.items = [NSArray arrayWithObjects:flexibleSpaceButtonItem, doneButtonItem, nil];
[self.view addSubview:toolbar];