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. canvas之绘制一张图片

    <canvas id="canvas" width="600" height="500" style="background ...

  2. 卷积神经网络之AlexNet网络模型学习

    ImageNet Classification with Deep Convolutional Neural Networks 论文理解  在ImageNet LSVRC-2010上首次使用大型深度卷 ...

  3. 我编辑的JAVA日历程序

    class calendar { public static void main(String[]args) { int yearIn ; yearIn = Integer.parseInt(args ...

  4. 下载pubmed数据

    1 import requests 2 import json 3 4 search_url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils ...

  5. OD 实验(十一) - 对一个程序的破解

    程序: 点击安装程序 这是一个拼图程序 点击 Options -> Flash Sizes 程序会提示是未注册版本 点击一些选项的时候会提示该程序只给注册的用户 点击 Register 随便输入 ...

  6. thrift协议的服务进压力测试

    Thrift vs  Grpc内容如下链接 http://blog.csdn.net/dazheng/article/details/48830511 背景:Facebook 开发的远程服务调用框架 ...

  7. Proof for Floyd-Warshall's Shortest Path Derivation Algorithm Also Demonstrates the Hierarchical Path Construction Process

    (THIS BLOG WAS ORIGINALLY WRTITTEN IN CHINESE WITH LINK: http://www.cnblogs.com/waytofall/p/3732920. ...

  8. leetcode334

    public class Solution { public bool IncreasingTriplet(int[] nums) { var len = nums.Length; ) { retur ...

  9. c++builder自定义控件

    c++builder自定义控件 http://docwiki.embarcadero.com/CodeExamples/XE8/en/RegisterComponents_%28C%2B%2B%29 ...

  10. SVN用命令行更换本地副本IP地址

    1.运行svn info现连的svn信息 2.运行svn switch --relocate https://原来的地址 https://改过后的地址. svn help switch 查看switc ...