leftBarButtonItem问题

//解决UINavigationBar 的leftBarButtonItem点击范围过大问题
    UIImage *backImg = [UIImage imageNamed:@"fanhuibai"];
    UIButton *backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0.f, 0.f, backImg.size.width, backImg.size.height)];
    
    [backBtn setImage:backImg forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(popVC) forControlEvents:UIControlEventTouchUpInside];
    UIView *backBtnView = [[UIView alloc] initWithFrame:backBtn.bounds];
    backBtnView.bounds = CGRectOffset(backBtnView.bounds, 0, 0);
    [backBtnView addSubview:backBtn];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:backBtnView];
    
    //解决UINavigationController 自定义LeftBarButtonItem左边空隙问题
    UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    spaceItem.width = -10;
    self.navigationItem.leftBarButtonItems = @[spaceItem,leftItem];
- (void)popVC
{
    [self.navigationController popViewControllerAnimated:YES];
}

你可能感兴趣的:(leftBarButtonItem问题)