Ios UINavigationBarItem自定义-如何获取tabcontroller的角点?

Ios UINavigationBarItem自定义-如何获取tabcontroller的角点?,ios,objective-c,xcode,Ios,Objective C,Xcode,我想问一下如何将navigationtabbaritem的图标放在左角(左:0)和右角(右:0) 我的代码: _custombtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]; _custombtn.backgroundColor = [UIColor redColor]; [_custombtn setBackgroundImage:[UIImage imageNamed:@"ic_msg.png"]forState:

我想问一下如何将navigationtabbaritem的图标放在左角(左:0)和右角(右:0)

我的代码:

_custombtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
_custombtn.backgroundColor = [UIColor redColor];
[_custombtn setBackgroundImage:[UIImage imageNamed:@"ic_msg.png"]forState:UIControlStateNormal];
[_custombtn addTarget:self action:@selector(viewBn:) forControlEvents:UIControlEventTouchUpInside];
self.csbtn = [[UIBarButtonItem alloc]initWithCustomView:_custombtn];

请添加
spaceFix
以解决您的问题,这可能会有很大帮助

UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];    
aButton.frame = CGRectMake(0.0, 0.0, 44, 44);
UIBarButtonItem *aBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aButton];
[aButton addTarget:self action:@selector(rightBarButtonAction:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *spaceFix = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
spaceFix.width = -10;

self.navigationItem.rightBarButtonItems = @[spaceFix, aBarButtonItem];