1. 程式人生 > >iOS 開發中tabBarItem不顯示文字,只顯示圖片,且圖片居中顯示

iOS 開發中tabBarItem不顯示文字,只顯示圖片,且圖片居中顯示

//第一頁

HomePageViewController *homePageVC = [[HomePageViewControlleralloc] init];

UINavigationController *naviVC1 = [[UINavigationControlleralloc] initWithRootViewController:homePageVC];

    homePageVC.tabBarController.tabBar.tintColor = [UIColorredColor];

    homePageVC.tabBarItem = [[UITabBarItem

alloc] initWithTitle:nilimage:[UIImageimageNamed:@"[email protected]"] selectedImage:[[UIImageimageNamed:@"[email protected]"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

//homePageVC.title = @"首頁";

//tabBar圖片居中顯示,顯示文字的座標

    CGFloat offset = 5.0;

//tabBar圖片居中顯示,不顯示文字

    homePageVC.tabBarItem

.imageInsets = UIEdgeInsetsMake(offset, 0, -offset, 0);