我知道这类问题已被问过很多但我仍然找不到一种简单的方法来实现它。 现在,我有。
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBackground.png"] forBarMetrics:UIBarMetricsDefault];
CGRect ButtonSizeframe = CGRectMake(0, 0,50,50);
//Msg Navigator Button
UIButton *tmpButtonMsg = [UIButton buttonWithType:UIButtonTypeCustom];
[tmpButtonMsg setImage:[UIImage imageNamed:@"msg.png"] forState:UIControlStateNormal];
[tmpButtonMsg setImage:[UIImage imageNamed:@"msgPressed.png"] forState:UIControlStateHighlighted];
tmpButtonMsg.frame = ButtonSizeframe;
[tmpButtonMsg setTag:MsgBox];
[tmpButtonMsg addTarget:self action:@selector(ButtonNavigationAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *msgButton = [[UIBarButtonItem alloc] initWithCustomView:tmpButtonMsg];
//Tag Navigator Button
UIButton *tmpButtonTag = [UIButton buttonWithType:UIButtonTypeCustom];
[tmpButtonTag setImage:[UIImage imageNamed:@"UserTagIcon.png"] forState:UIControlStateNormal];
tmpButtonTag.frame = ButtonSizeframe;
[tmpButtonTag setTag:Tag];
[tmpButtonTag addTarget:self action:@selector(ButtonNavigationAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *tagButton = [[UIBarButtonItem alloc] initWithCustomView:tmpButtonTag];
NSArray *myArray = [[NSArray alloc] initWithObjects:msgButton,tagButton,nil];
[self.navigationItem setRightBarButtonItems:myArray animated:YES];
我希望两个按钮的方形尺寸(带有toolBar高度),它们之间没有空格,并且向右对齐。 我认为我在堆栈上阅读了所有问题(我试过但没有找到一个简单的方法来做到这一点,我在这里想到什么?(为什么Apple会做这样的显而易见的事情,如此不方便或者它?'像往常一样我的错吗?)