For the tab bar (Uitabbar), when the Tabbaritem does not need title as long as the image, the image below will occupy a space.
We can set the offset by tabbaritem.imageinsets so that the image icon is centered.
(Note: Top and bottom are set to the opposite number, otherwise the image size will change.) )
Import UIKit
Class MainTabViewController:UITabBarController
{
Override func viewDidLoad()
{
super.viewDidLoad()
//A total of two views are included
Let qqView = QQViewController()
//qqView.title = ""
Let skypeView = SkypeViewController()
//skypeView.title = ""
/ / Declare two view controllers separately
Let qq = UINavigationController(rootViewController:qqView)
qq.tabBarItem.image = UIImage(named:"qq")
qq.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
Let skype = UINavigationController(rootViewController:skypeView)
skype.tabBarItem.image = UIImage(named:"skype")
skype.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
self.viewControllers = [qq, skype]
}
}