Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在IOS中自定义后退按钮_Ios_Cocoa Touch - Fatal编程技术网

在IOS中自定义后退按钮

在IOS中自定义后退按钮,ios,cocoa-touch,Ios,Cocoa Touch,如何使用barmetrics在iOS中创建没有文本的自定义后退按钮 我想做点像 你可以将其放在你的应用程序委托中,它会将背景图像设置为应用程序中的所有后退按钮(当然,对于控制状态和条形图指标) 编辑: 如果您想更改某些内容,请使用以下代码: - (void)setBackButton { UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [backButton setImage:[UIIma

如何使用barmetrics在iOS中创建没有文本的自定义后退按钮

我想做点像

你可以将其放在你的应用程序委托中,它会将背景图像设置为应用程序中的所有后退按钮(当然,对于控制状态和条形图指标)

编辑: 如果您想更改某些内容,请使用以下代码:

- (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];
}  

像这样的怎么样

UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(YourFrame)];

[backButton setTitle:@"<" forState:UIControlStateNormal];

[backButton addTarget:self action:@selector(callSelectorMethod) forControlEvents:UIControlEventTouchUpInside];

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

[backButton release],backButton=nil;
UIButton*backButton=[[UIButton alloc]initWithFrame:CGRectMake(YourFrame)];

[backButton setTitle:@“以下是解决方案:

 UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"BackButton.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(popBack) forControlEvents:UIControlEventTouchUpInside];
    [button setFrame:CGRectMake(0, 0, 32, 32)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

多亏了

你试过了吗?我试过了。图像即将出现,但它采用了后退按钮的全尺寸,而不是图像尺寸。“后退”也将显示:(你可以使用第二种方法,为此,你可以在谷歌上找到很多解决方案。点击此链接此解决方案不是100%好,因为它删除了uinavigationcontroller的滑动转换。这是一个经常被问到的问题!检查:
 UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"BackButton.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(popBack) forControlEvents:UIControlEventTouchUpInside];
    [button setFrame:CGRectMake(0, 0, 32, 32)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];