Adjust iOS TabBar item title to the centre of it

//TabBarController code:

self.delegate=self;
self.tabBarController.tabBar.delegate=self;

CGRect viewFrame=self.tabBar.frame;
viewFrame.origin.y -=0;![enter image description here][1]
viewFrame.origin.x -=0;
viewFrame.size.height=30;
self.tabBar.frame=viewFrame;

firstViewController = [[FirstViewController alloc] initWithNibName:nil bundle:NULL];
secondViewController = [[SecondViewController alloc] initWithNibName:nil bundle:NULL];

NSArray *twoViewControllers = [[NSArray alloc] initWithObjects:
                                       self.firstViewController, self.secondViewController, nil];

self.viewControllers=twoViewControllers;



//    ====================================================
//    
//    FirstViewController code in initWithNibName: 
//    
//    To set the title of the first tabbar item:


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"Article view";
        NSLog(@"count = %d",[self.tabBarController.tabBar.items count]);

    }
    return self;
}

//How can i make the first tabbar item title “Article View” to the Center without adding any //image to the tabbaritem ?

// similar to the below tabbar items screenshot.

  • Unable to programatically create a UIViewController in Swift
  • How can I get index path of cell on switch change event in section based table view
  • Uploading image with AFNetworking with null parameter doesn't work
  • JPG image doesn't load with UIImage imageNamed
  • Use NSURLIsExcludedFromBackupKey without crashing on iOS 5.0
  • Swift : No Matter what I do CIDetector is always nil
  •   [1]: http://i.stack.imgur.com/xBpVH.png
    
    
    Thanks in advance.
    

    Solutions Collect From Internet About “Adjust iOS TabBar item title to the centre of it”

    Replace the initWithNibName method

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            self.title = @"Article view";
            self.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
            NSLog(@"count = %d",[self.tabBarController.tabBar.items count]);
        }
        return self;
    }
    

    self.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0); this line here adjusts the position of the image for the tabBarItem in the manner :

    Shift the image in x-direction ‘+5’ and in y-direction ‘-5’ from the
    default position.

    Play with UIEdgeInsetsMake and have fun. Cheers.