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. Java中static关键字介绍

    static关键字主要有两种作用: 第一,为某特定数据类型或对象分配单一的存储空间,而与创建对象的个数无关. 第二,实现某个方法或属性与类而不是对象关联在一起 具体而言,在Java语言中,static ...

  2. Linux 之 利用Google Authenticator实现用户双因素认证

    一.介绍:什么是双因素认证 双因素身份认证就是通过你所知道再加上你所能拥有的这二个要素组合到一起才能发挥作用的身份认证系统.双因素认证是一种采用时间同步技术的系统,采用了基于时间.事件和密钥三变量而产 ...

  3. Flask之模板之特殊变量和方法

    3.6 Flask中的特殊变量和方法: 在Flask中,有一些特殊的变量和方法是可以在模板文件中直接访问的. config 对象: config 对象就是Flask的config对象,也就是 app. ...

  4. django之jquery完成ajax

    使用Ajax 使用视图通过上下文向模板中传递数据,需要先加载完成模板的静态页面,再执行模型代码,生成最张的html,返回给浏览器,这个过程将页面与数据集成到了一起,扩展性差 改进方案:通过ajax的方 ...

  5. Halcon算子之shape_trans,用于变换区域的形状

    函数原型:shape_trans(Region : RegionTrans : Type : ) *shape_trans*仍然是区域,smallest_rectangle1可以获得四个角的坐标 函数 ...

  6. leetcode125

    public class Solution { Stack<char> S = new Stack<char>(); Queue<char> Q = new Que ...

  7. mysql update更新带子查询的实现方式

    现在要做一下数据移植,需要更新相关的数据,需要在mysql中更新时不能将更新的表作为查询的表. 总结一下: 一:单表更新时 例如: update customer set category = 1 W ...

  8. <转> win7下破解已安装的VS2008

    http://renfan.blog.51cto.com/3466724/754301 在win7系统下,已安装的VS2008维护界面是不显示序列号输入的,需要按以下步骤进行才能破解 1.点击“卸载/ ...

  9. visjs使用小记-1.创建一个简单的网络拓扑图

    1.插件官网:http://visjs.org/ 2.创建一个简单的网络拓扑图 <!doctype html> <html> <head> <title> ...

  10. C#窗体中将窗体按钮与键盘关联

    当击了某个按钮相当于是按了某个键盘上按键 private void btnPre_Click(object sender, EventArgs e) {     this.treeView1.Focu ...