在 UITabBarController 上添加子视图 [英] AddSubView on UITabBarController
问题描述
我尝试在 UIViewController
上添加 UIView
:
I try to add UIView
on UIViewController
:
AppDelegate *md = (AppDelegate*)[[UIApplication sharedApplication] delegate];
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 150, 44)];
[view setBackgroundColor:[UIColor yellowColor]];
[md.tab.view addSubview:view];
而且我注意到 UIView 不是从以下位置开始的:
And i noticed that the UIView not start from :
我在 MainWindow.Xib 上创建了 TabBarController
I create the TabBarController on The MainWindow.Xib
推荐答案
这是正确的行为,假设您将视图添加到 UITabBarViewController
的视图.一个标签栏控制器占据了整个屏幕——底部的标签,以及上面的标签内容.
That's correct behaviour, assuming you're adding your view to the UITabBarViewController
's view. A tab bar controller takes up the entire screen - the tabs at the bottom, and the tab content above that.
听起来好像您想向标签栏而不是视图控制器添加视图.为此,您应该使用标签栏控制器的 tabBar
属性.
It sounds as if you want to add a view to the tab bar rather than the view controller. To do this you should use the tabBar
property of your tab bar controller.
这篇关于在 UITabBarController 上添加子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!