我将这些代码用于自定义后退按钮
UIImage *buttonImage = [UIImage imageNamed:@"back-button-2.png"];
//create the button and assign the image
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
这是返回功能
-(void)back {
// Tell the controller to go back
[self.navigationController popViewControllerAnimated:YES];
}
自定义后退按钮即将出现,但它不起作用。