默认解决方案不合适:

  • 更改以前的 ViewController 标题 - 我需要制作自己的功能来控制按钮触摸
  • 创建一个 leftBarButtonItem 并隐藏 backBarButtonItem - leftBarButtonItem 看起来不像默认的 backBarButtonItem。
  • 最佳答案

    这是创建自定义 leftBarButtonItem 的示例:

    UIImage *buttonImage = [UIImage imageNamed:@"backbutton.png"];
    UIButton *aButton = [UIbutton buttonWithType:UIButtonTypeCustom];
    [aButton setImage:buttonImage forState:UIControlStateNormal];
    aButton.frame = CGRectMake(0.0,0.0,buttonImage.size.width,buttonImage.size.height);
    [aButton addTarget:self action:@selector(aSelector) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:aButton];
    self.navigationItem.leftButtonItem = backButton;
    

    希望能帮助到你...

    编辑:

    试试这个...
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"yourimage.jpg"] style:UIBarButtonItemStyleBordered target:self action:@selector(aSelector)];
    self.navigationItem.leftBarButtonItem = backButton;
    

    我不记得backbutton是什么类型的按钮,尝试将默认样式更改为其他。祝你好运!

    关于ios - 如何使 leftBarButtonItem 看起来像 backBarButtonItem?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7397911/

    10-09 02:34