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...
811 0
|
图形学 API C语言
【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记12 Custom Views视图绘制1
这一话来讲解一下视图的绘制,首先介绍一下相关的结构体 视图中的所有coordinate(坐标)的类型都是CGFloat,CGFloat在Swift中是结构体,在处理视图绘制和手势识别的时候我们使用的都是CGFloat,不要用我们常规的Double和Float。
952 0
ios项目常用模板框架之UITabBar+Nav
在实际的项目开发中总是有几个比较常见的模板,小编这几天给大伙出几期常用模板的博客,希望大家多提宝贵的意见! 这几个月最常用的莫过于Nav+UITabBar模板了;在实际的项目中,我比较侧重于纯代码,比较不喜欢拖控件,至于利弊在这里不多说了,言归正传。
849 0
|
Swift iOS开发
swift语言IOS8开发战记4.custom tableViewCell
第三话中讲解了如何利用系统内置的cell格式,这一话来谈谈如何自定义cell格式.在stroyboard中通过拖拽为cell添加内容,并且通过属性检测器修改样式,下面是我简单设置的一个自定义cell。
969 0
|
19天前
|
开发框架 前端开发 Android开发
安卓与iOS开发中的跨平台策略
在移动应用开发的战场上,安卓和iOS两大阵营各据一方。随着技术的演进,跨平台开发框架成为开发者的新宠,旨在实现一次编码、多平台部署的梦想。本文将探讨跨平台开发的优势与挑战,并分享实用的开发技巧,帮助开发者在安卓和iOS的世界中游刃有余。
|
10天前
|
Java 调度 Android开发
安卓与iOS开发中的线程管理差异解析
在移动应用开发的广阔天地中,安卓和iOS两大平台各自拥有独特的魅力。如同东西方文化的差异,它们在处理多线程任务时也展现出不同的哲学。本文将带你穿梭于这两个平台之间,比较它们在线程管理上的核心理念、实现方式及性能考量,助你成为跨平台的编程高手。