gpt4 book ai didi

ios - IOS自定义后退按钮

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:08:47 24 4
gpt4 key购买 nike

如何使用气压在 iOS 中制作没有文本的自定义后退按钮?

我想做类似 http://a397.phobos.apple.com/us/r1000/081/Purple/v4/e6/be/2d/e6be2d9e-dc95-7e44-b1ed-9386fa9f4d02/mzl.zwjkpepo.320x480-75.jpg 的东西

最佳答案

[[UIBarButtonItem appearance]
setBackButtonBackgroundImage:[UIImage imageNamed:@"back_button.png"]
forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

您可以将它放在您的应用委托(delegate)中,它会将背景图像设置为应用中的所有后退按钮(当然是针对该控件状态和栏指标)。

编辑:如果您想要不同的东西,请使用此代码:

- (void)setBackButton
{
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setImage:[UIImage imageNamed:@"BackButton.png"] forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(backButtonTapped:) forControlEvents:UIControlEventTouchUpInside];[button setFrame:CGRectMake(0, 0, 32, 32)];

self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:backButton] autorelease];
}

- (void)backButtonTapped:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}

关于ios - IOS自定义后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14779345/

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