gpt4 book ai didi

iphone - 为自定义 UIBarButtonItem 设置文本

转载 作者:行者123 更新时间:2023-12-03 18:37:17 25 4
gpt4 key购买 nike

我需要为自定义 UIBarButtonItem 设置标题。

我有以下代码:

UIButton* backToRecent = [UIButton buttonWithType:UIButtonTypeCustom];
[backToRecent setImage:[UIImage imageNamed:@"back.png"]forState:UIControlStateNormal];

[backToRecent addTarget:self action:@selector(backToRecent) forControlEvents:UIControlEventTouchUpInside];
[backToRecent setFrame:CGRectMake(0, 0, 60, 30)];

UIBarButtonItem* backButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backToRecent];
[backButtonItem setTitle:@"Recent"];
partViewController.navigationItem.leftBarButtonItem = backButtonItem;
[backButtonItem release];

但是按钮显示时没有“最近”文本。

最佳答案

穆罕默德,我怀疑你已经解决了这个问题,但这里有一个简单的方法。希望这对遇到同样问题的人有所帮助:

    UIBarButtonItem * backButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Recent" style:UIBarButtonItemStyleBordered target:self action:@selector(backToRecent)];
self.navigationItem.leftBarButtonItem = backButtonItem;

关于iphone - 为自定义 UIBarButtonItem 设置文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10734215/

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