巴扣之间的空间

时间:2014-06-08 10:25:22

标签: ios uinavigationcontroller uibarbuttonitem uinavigationitem

我创建3个她的栏按钮,并希望将其分配给右侧导航项目。我希望在那之间有空间。我的代码空间很小,我试图扩大但不能得到它。我的代码

    UIBarButtonItem *actionBarButton = [UIBarButtonItem.alloc initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(presentActivity)];
self.navigationItem.leftBarButtonItem = backButton;
UIBarButtonItem *prevBarButton = [UIBarButtonItem.alloc initWithImage:MHGalleryImage(@"left_arrow.png") style:UIBarButtonItemStyleBordered target:self action:@selector(prevButtonAction:)];
UIBarButtonItem *nextBarButton = [UIBarButtonItem.alloc initWithImage:MHGalleryImage(@"right_arrow.png") style:UIBarButtonItemStyleBordered target:self action:@selector(nextButtonAction:)];
UIBarButtonItem *flex = [UIBarButtonItem.alloc initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
self.navigationItem.rightBarButtonItems = @[actionBarButton, flex, flex, flex, flex, flex, flex, flex, flex, flex, flex, flex, flex, nextBarButton, flex, flex, flex, flex, flex, flex, prevBarButton, flex];

1 个答案:

答案 0 :(得分:0)

明确定义flex条形按钮项的宽度,如下所示:

UIBarButtonItem *flex = [UIBarButtonItem.alloc initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                                                    target:nil
                                                                    action:nil];
NSLog(@"before -- %f",flex.width);
flex.width = 44;
NSLog(@"after -- %f",flex.width);

self.navigationItem.rightBarButtonItems = @[actionBarButton, flex, nextBarButton, flex, prevBarButton, flex];