gpt4 book ai didi

ios - 在我的标签栏后面放置一个 View

转载 作者:行者123 更新时间:2023-12-01 18:25:36 24 4
gpt4 key购买 nike

我有一个带有 3 个按钮的选项卡栏,每个按钮加载一个不同的 Controller ,因此有一个不同的 View 。
我想在我的标签栏后面放置一个 UIView,以便它在所有 3 个不同的子 Controller 上可见。

我怎样才能做到这一点?
enter image description here

最佳答案

这很容易(这是使用 Storyboard):

• 创建UITabBarController 的子类(我称之为“TabViewController”)。

• 在您的 Storyboard中,选择您的UITabBarViewController ,并给它类 `TabViewController(在右侧栏,第 3 部分,自定义类)。

• 在您的TabViewController.m文件,使用以下代码:

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.

UIView *theView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
theView.backgroundColor = [UIColor redColor];
[self.view addSubview:theView];

[self.view bringSubviewToFront:self.tabBar];
}

你可以用 theView 做任何你想做的事在添加到 self.view 之前,这里我只是在 (50, 50) 的位置创建了一个 50x50 的红色方 block 。该 View 将保持在一切之上!

运行并玩得开心!

关于ios - 在我的标签栏后面放置一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14040770/

24 4 0