There are actually several ways to align panel buttons. Try adjusting the position of the button name as follows:
[self.navigationItem.rightBarButtonItem setTitlePositionAdjustment:UIOffsetMake(-10, -10) forBarMetrics:UIBarMetricsDefault];
-10 -10 - for example,
OR
you can initialize your newGameItem with a custom UIButton . The user button is a subclass of UIButton with an overridden method
- (UIEdgeInsets)alignmentRectInsets { return UIEdgeInsetsMake(0, -10, 0, 15.0f);
then initialize newGameItem
CustomBarButton *button = [CustomBarButton buttonWithType:UIButtonTypeCustom]; [button setTitle:@"New game" forState:UIControlStateNormal]; button.frame = CGRectMake (0, 0, 60, 40); [button addTarget:self action:@selector(newGame) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *newGameItem = [[UIBarButtonItem alloc] initWithCustomView:button]; self.navigationItem.rightBarButtonItem = newGameItem;
source share