gpt4 book ai didi

ios - 你如何设置 UINavigationBar 的标题

转载 作者:行者123 更新时间:2023-11-28 22:09:06 25 4
gpt4 key购买 nike

我有一个基于选项卡的应用程序,我正在尝试更改 UINavigationBar 的标题,当单击一个按钮时加载了一个新的 Uiview 但没有任何显示!

我这样创建栏:

navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 60)];
navBar.barTintColor = [UIColor colorWithRed:0.082 green:0.118 blue:0.141 alpha:1.0];
navBar.tintColor = [UIColor whiteColor];
navBar.translucent = NO;
[self.view addSubview:navBar];

然后在我尝试更改的方法中:

UIView *sendASongView = [[UIView alloc] init];
[sendASongView setFrame: CGRectMake(0, 60, screenWidth, screenHeight-110)];
[sendASongView setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:sendASongView];
navBar.topItem.title = @"Send";

最佳答案

您可以创建一个 UINavigationController 并将其用作 viewController 的容器。

- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {

self.statusLabel.text = @"You're logged in as";

HomeNavViewController *profileviewController = [[HomeNavViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: profileviewController] ;


CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];
[self presentModalViewController:nav animated:NO];

}

覆盖 YourViewController 中的方法 viewWillAppear

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated] ;
self.title = @"Sender" ;
}

关于ios - 你如何设置 UINavigationBar 的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23282708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com