【问题标题】:Space between barbuttons条形按钮之间的空间
【发布时间】:2014-06-08 10:25:22
【问题描述】:

我创建了 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];

【问题讨论】:

标签: ios uinavigationcontroller uibarbuttonitem uinavigationitem


【解决方案1】:

像这样显式定义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];

【讨论】:

    猜你喜欢
    • 2014-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多