gpt4 book ai didi

ios - 图像和标题有时未显示在导航栏后退按钮上

转载 作者:行者123 更新时间:2023-11-29 13:02:50 27 4
gpt4 key购买 nike

如何在导航栏中创建带有图像和标题的后退按钮。下面是我的代码,其中按钮上的图像和标题在时间上都看不到,如何实现这一点。请给我建议。

 UIButton *nav_BackButton1=[[UIButton alloc] initWithFrame:CGRectMake(5,10 ,60, 24)];
nav_BackButton1.layer.borderColor=[[UIColor blackColor] CGColor];
nav_BackButton1.layer.borderWidth=1.0;
[nav_BackButton1 setTitle:@"Ik" forState:UIControlStateNormal];
[nav_BackButton1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[nav_BackButton1 setTitleEdgeInsets:UIEdgeInsetsMake(0,30, 0, 0)];
[nav_BackButton1 setImage:[UIImage imageNamed:@"ic_action_bar_up.png"] forState:UIControlStateNormal];
[nav_BackButton1 setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 35)];
[nav_BackButton1 addTarget:self action:@selector(backTOChoiceScreen:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backBarBtn = [[UIBarButtonItem alloc] initWithCustomView:nav_BackButton1];
self.navigationItem.leftBarButtonItem=backBarBtn;

最佳答案

使用方法 setBackgroundImage:forState: 而不是 setImage:forState: 将背景图像设置为 nav_BackButton1

关于ios - 图像和标题有时未显示在导航栏后退按钮上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19381584/

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