leftBarButtonItem位置不正确

时间:2015-02-10 04:33:02

标签: ios objective-c uinavigationcontroller uinavigationbar uinavigationitem

我正在尝试在导航栏中添加自定义按钮,但导航栏中的位置偏离左侧。这是我正在看的(注意“菜单”按钮太远了):

enter image description here

以下是我将按钮添加到当前viewcontroller的方法。在ViewDidLoad中调用setupMenu。

 -(void)setupMenu{
    self.navigationItem.leftBarButtonItem = [self leftMenuBarButtonItem];
}

- (UIBarButtonItem *)leftMenuBarButtonItem {
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"GuidanceNavMenu", nil) style:UIBarButtonItemStylePlain target:self action:@selector(popToOpenMenu)];

    NSMutableParagraphStyle *paragraphStyle = NSMutableParagraphStyle.new;

    [menuButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                        [UIFont openSansFontOfSize:14.0f], NSFontAttributeName,
                                        [UIColor blackColor], NSForegroundColorAttributeName,
                                        nil]
                              forState:UIControlStateNormal];

    return menuButton;
}

0 个答案:

没有答案