gpt4 book ai didi

iphone - iOS:更改后退按钮的色调?

转载 作者:可可西里 更新时间:2023-11-01 06:18:32 25 4
gpt4 key购买 nike

我有一个推送 UIViewController 的导航 Controller 。当用户按下某个按钮时,我想更改导航项后退按钮的色调。这可能吗?我试过使用 [UIBarButtonItem appearance] setTintColor: 但它只适用于初始化(例如在 viewDidLoad 中),否则无效。

最佳答案

试试这个……

您需要将 UIBarButtonItem 与自定义 View 一起使用。像这样:

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 70, 30)];
[button addTarget:target action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"back_button.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"back_button_tap.png"] forState:UIControlStateHighlighted];
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

然后将按钮放到导航栏上,通常在带有 UINavigationController 的 Controller 中:

self.navigationItem.leftBarButtonItem = buttonItem;

关于iphone - iOS:更改后退按钮的色调?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12407716/

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