UIBarButtonItem设置边距

leftBarButtonItem设置左边距,rightBarButtonItem设置右边距

UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 44)];

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

    [backButton setBackgroundImage:[UIImage imageNamed:@"fanHuiC60.88"] forState:UIControlStateNormal];

    

    UIBarButtonItem *backBtnI = [[UIBarButtonItem alloc] initWithCustomView:backButton];

    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]

                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace

                                       target:nil action:nil];

    negativeSpacer.width = -17;

    self.navigationItem.leftBarButtonItems = @[negativeSpacer,backBtnI];

你可能感兴趣的:(UIBarButtonItem设置边距)