ios7 - Custom UItabbar has a gap in the bottom

简介:

Im trying to create a custom UITabbar using images for the selected and unselected states.

this is my code:

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];

This image shows the problem, the red color is the gap:

enter image description here

EDIT to add the code to create the UITabbar

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

I appreciate any help you guys can offer

share | edit | flag
 
   
   
how high Tabbar_on_01? –   Ilario  Nov 15 at 12:37
   
   
the @2x image is 128x100px I also tried with 128x98px and got the same problem. –   FelipeOliveira  Nov 15 at 12:47 
   
   
Is your view designed with Interface Builder, or do you create it programmatically? –   zbMax  Nov 15 at 13:27
   
   
programmatically zbMax –   FelipeOliveira  Nov 15 at 13:39
   
   
Can you edit your question and add the code creating the tabbar please? By the way, follow this guidelines page for your icon dimension : developer.apple.com/library/ios/documentation/userexperience/… –   zbMax Nov 15 at 13:53
   
add / show 1 more comment
  start a bounty

1 Answer

I finally found the solution. Changing the imageInsets of each tabbarItem did the trick.

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);
share | edit | flag
欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 572064792 | Nodejs:329118122 做人要厚道,转载请注明出处!





















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sunshine-anycall/p/3449372.html ,如需转载请自行联系原作者
相关文章
|
iOS开发
iOS中 UITabBarController中自定义UITabBar
1.创建多个视图控制器,放如UITabBarController中 AViewController *aa = [[AViewController alloc] init]; UINavigationController* ayNav = [[UINavigationCont...
779 0
ios项目常用模板框架之UITabBar+Nav
在实际的项目开发中总是有几个比较常见的模板,小编这几天给大伙出几期常用模板的博客,希望大家多提宝贵的意见! 这几个月最常用的莫过于Nav+UITabBar模板了;在实际的项目中,我比较侧重于纯代码,比较不喜欢拖控件,至于利弊在这里不多说了,言归正传。
820 0
|
1月前
|
API 数据安全/隐私保护 iOS开发
利用uni-app 开发的iOS app 发布到App Store全流程
利用uni-app 开发的iOS app 发布到App Store全流程
91 3
|
3月前
|
存储 iOS开发
iOS 开发,如何进行应用的本地化(Localization)?
iOS 开发,如何进行应用的本地化(Localization)?
122 2
|
3月前
|
存储 数据建模 数据库
IOS开发数据存储:什么是 UserDefaults?有哪些替代方案?
IOS开发数据存储:什么是 UserDefaults?有哪些替代方案?
40 0
|
3月前
|
安全 编译器 Swift
IOS开发基础知识: 对比 Swift 和 Objective-C 的优缺点。
IOS开发基础知识: 对比 Swift 和 Objective-C 的优缺点。
93 2
|
3月前
|
API 开发工具 iOS开发
iOS 开发高效率工具包:10 大必备工具
iOS 开发高效率工具包:10 大必备工具
48 1
|
10天前
|
API 定位技术 iOS开发
IOS开发基础知识:什么是 Cocoa Touch?它在 iOS 开发中的作用是什么?
【4月更文挑战第18天】**Cocoa Touch** 是iOS和Mac OS X应用的核心框架,包含面向对象库、运行时系统和触摸优化工具。它提供Mac验证的开发模式,强调触控接口和性能,涵盖3D图形、音频、网络及设备访问API,如相机和GPS。是构建高效iOS应用的基础,对开发者至关重要。
12 0