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:

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

asked Nov 15 at 12:19
 
   
   
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/… –  zbMaxNov 15 at 13:53
   

add / show 1 more comment

 

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);
answered Nov 18 at 15:56

ios7 - Custom UItabbar has a gap in the bottom的更多相关文章

  1. Shape画圆形控件

    这里涉及到shape的运用,这仅仅是一个实例 circle.xml <?xml version="1.0" encoding="utf-8"?> & ...

  2. Android 阴影,圆形的Button

    MainActivity.java package com.kale.gridlayout; import android.app.Activity; import android.graphics. ...

  3. PhotoSwipe中文API(三)

    http://photoswipe.com/documentation/api.html 所有的方法和这个网页上列出的属性是公开的.如果你想看看例子什么API可以做的,拿在默认PhotoSwipe U ...

  4. Android TabHost设置setCurrentTab(index),当index!=0时,默认加载第一个tab问题解决方法。

    最近在用TabHost,默认希望显示第2个tab,发现总是加载第三个tab的同时加载第一个,解决方法如下: 1.首先查看addTab(TabSpec tabSpec)源代码: /** * Add a ...

  5. 【转】Android使用XML Shape绘制带阴影效果的圆形按钮

    众所周知,在Android开发里,为了优化在各种分辨率设备上的显示效果,同一份图片素材往往要提供mdpi.hdpi.xhdpi三种(以前还有ldpi), 尤其是按钮类的素材,考虑到normal.pre ...

  6. 放弃 Electron,拥抱 WebView2!JavaScript 快速开发独立 EXE 程序

    Electron 不错,但也不是完美的. Electron 带来了很多优秀的桌面软件,但并不一定总是适合我们的需求. 多个选择总是好事! 我使用 Electron 遇到的一些麻烦 1.Electron ...

  7. 【原】iOS学习之UITabBar的隐藏

    当页面使用 UITabBarController + UINavigationController 框架的时候,当跳转到详情页面的时候,如果 UITabBar 仍然存在的话就会造成逻辑混乱,用户体验也 ...

  8. 【iOS】Alamofire库在iOS7下设置Head无效的问题

    声明  欢迎转载,但请保留文章原始出处:)  博客园:http://www.cnblogs.com 农民伯伯: http://over140.cnblogs.com 正文 同样的代码在iOS8下没有问 ...

  9. ios7 ios8 cell中下划线偏移(separator Insets)处理方法

    在ios7中,UITableViewCell左侧会有默认15像素的空白.这时候,设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉. 但是在ios8中,设置setS ...

随机推荐

  1. linux编辑器使用记录

    超强大vim配置文件: wget  http://files.cnblogs.com/ma6174/vimrc.zip unzip  -f  vimrc.zip  -d  ~/ 一.vim编辑器 进入 ...

  2. bash中常用的快捷键

    常用快捷键 ctrl+c 强制终止当前命令 ctrl+l 清屏(clear) ctrl+a 光标移动到命令行行首 ctrl+e 光标移动到命令行行尾 ctrl+u 从光标所在位置删除到行首 ctrl+ ...

  3. 5.Redis 发布订阅

    转自:http://www.runoob.com/redis/redis-tutorial.html Redis 发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub ...

  4. RHCE7-学习里程 root 密码重置换

    一.root 密码重置换 当忘记root 密码后,可以按照以下方法重置 root 密码 1.重启动电脑,出现如下界面,按  上  下 键盘, 选择   (core)--再按e 2.在下图linux16 ...

  5. xUtils怎么post请求上传字符串

    xUtils算是一个非常实用老牌的框架了,但是有些情况,特别是网络请求部分,总是不太方便.需要折腾下才了解用法.今天来聊聊网络模块的用法. 其实看例子就明白了,post JSON数据也是一样道理,这里 ...

  6. mac os、linux及unix之间的关系

    unix 是由贝尔实验室开发的多用户.多任务操作系统 linux是一类Unix操作系统的统称,严格来说,linux系统只有内核叫“linux”,而linux也只是表示其内核,但因为习惯使然,人们 习惯 ...

  7. STL - Vector迭代器简单应用之计算元素和

    Description 用vector向量容器装入10个整数,然后,使用迭代器iterator和accumulate算法统计出这10个元素的和 Solution #include "stda ...

  8. 全文搜索技术—Lucene

    1.   内容安排 实现一个文件的搜索功能,通过关键字搜索文件,凡是文件名或文件内容包括关键字的文件都需要找出来.还可以根据中文词语进程查询,并且支持多种条件查询. 本案例中的原始内容就是磁盘上的文件 ...

  9. VUE+WebPack游戏设计:欲望都市城市图层的设计

  10. space defender,太空版植物大战僵尸 游戏基本框架的设计