I want to align the tab bar item images in my tab bar. I know I can do it in IB which I did and it worked. However I want to do it programatically. I'm trying to do it in AppDelegate. Following is my code which doesn't work. Can anyone point me what I'm doing wrong?
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabBarController = storyboard.instantiateViewController(withIdentifier: "RootTabBarController") as! UITabBarController
let tabArray = tabBarController.tabBar.items as NSArray?
let homeTabItem = tabArray?.object(at: 0) as! UITabBarItem
homeTabItem.imageInsets = UIEdgeInsetsMake(12.0, 0.0, -12.0, 0.0)