簡體   English   中英

ios7 - 自定義UItabbar底部有一個空白

[英]ios7 - Custom UItabbar has a gap in the bottom

我試圖使用圖像為選定和未選擇狀態創建自定義UITabbar。

這是我的代碼:

if ([UIImage instancesRespondToSelector:@selector(imageWithRenderingMode:)]) {

    tab_01_on_image = [[UIImage imageNamed:@"Tabbar_on_01"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tab_01_off_image = [[UIImage imageNamed:@"Tabbar_off_01"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

} else {
    tab_01_on_image = [UIImage imageNamed:@"Tabbar_on_01"] ;
    tab_01_off_image = [UIImage imageNamed:N@"Tabbar_off_01"] ;

}

[[[self.tabBarController.tabBar items] objectAtIndex:index] setFinishedSelectedImage:tab_01_on_image withFinishedUnselectedImage:tab_01_off_image];

此圖顯示問題,紅色是差距:

在此輸入圖像描述

編輯添加代碼以創建UITabbar

self.tabBarController = [[BaseTabbarController alloc] init];
self.tabBarController.delegate = self;
self.tabBarController.viewControllers = @[navControll1, navControll2, navControll3, navControll4, navControll5];
self.window.rootViewController = self.tabBarController;

我感謝你們提供的任何幫助

我終於找到了解決方案。 更改每個tabbarItem的imageInsets就可以了。

tabBarItem1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem2.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem3.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem4.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem5.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM