1

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

 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;
4

2 回答 2

1

使用 methodsetBackgroundImage:forState:而不是setImage:forState:for 将背景图像设置为nav_BackButton1.

于 2013-10-15T12:58:20.033 回答
0

尝试改变;

 self.navigationItem.leftBarButtonItem = backBarBtn;

和:

 self.navigationItem.hidesBackButton = YES;
 self.navigationItem.leftBarButtonItem = backBarBtn;
于 2013-10-15T12:59:54.197 回答