1

是否可以平衡按钮的位置(Safari 中的示例工具栏)?

    UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] 
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemCompose 
                                       target:self action:@selector(support:)];

        UIBarButtonItem *next = [[UIBarButtonItem alloc] 
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemPlay 
                                       target:self action:@selector(support:)];
        [self.navigationController.toolbar setItems:[NSArray arrayWithObjects:infoButton, next,nil] animated:YES];

替代文字

4

1 回答 1

7

您需要在两个按钮项之间添加一个灵活的空间项。

Apple 的UICatalog 示例代码中提供了更多详细信息。例如:

// flex item used to separate the left groups items and right grouped items
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                                                                          target:nil
                                                                          action:nil];
于 2010-03-12T06:51:37.050 回答