gpt4 book ai didi

ios - 如何向 UINavigationBar 添加按钮?

转载 作者:IT王子 更新时间:2023-10-29 07:28:25 26 4
gpt4 key购买 nike

如何以编程方式向 UINavigationBar 添加按钮?

最佳答案

NavigationBar 上设置 rightbutton 的示例代码。

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
style:UIBarButtonItemStyleDone target:nil action:nil];
UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Title"];
item.rightBarButtonItem = rightButton;
item.hidesBackButton = YES;
[bar pushNavigationItem:item animated:NO];

但通常您会有一个 NavigationController,使您能够编写:

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationItem.rightBarButtonItem = rightButton;

关于ios - 如何向 UINavigationBar 添加按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2504351/

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