ios7 - Custom UItabbar has a gap in the bottom


3down votefavorite

 

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

ios iphone ios7 uitabbarcontroller uitabbar


share|edit|flag

edited Nov 18 at 15:34

 

 

asked Nov 15 at 12:19

FelipeOliveira
264

 

   
   

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

  start a bounty

1 Answer

activeoldestvotes


up vote1down vote

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

answered Nov 18 at 15:56

欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 330987132 | Go:217696290 | Python:336880185 | 做人要厚道,转载请注明出处!http://www.cnblogs.com/sunshine-anycall/p/3449372.html

时间: 2024-08-03 04:07:00

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

Xcode9和iOS 11遇到的一些问题如何解决

1.升级到Xcode9后新建一个工程,直接报错,如下图: 因为在iOS7中引入的Top Layout Guide和Bottom Layout Guide,这些布局在iOS 11中被弃用,取而代之的是Safe Area Layout Guide. 解决办法就是将下图中系统默认勾选的两项去掉就可以了 2.项目中用到了RealReachability来实时检测网络,但是用Xcode9打开后运行直接报错,如图: 解决办法:将缺少文件.m都在Compile Sources中添加上就可以了 3.MJRefr

GNOME 3.26 将对控制中心进行大改进

GNOME 3.26 桌面环境的开发正在按计划继续进行,目前,第三个里程碑(GNOME 3.25.3)已经发布,包含多个组件和应用程序的各种更新和错误修复. GNOME 控制中心是 GNOME 桌面的重要组成部分,GNOME 3.25.3 开发版为其增加了一系列改进,包括网络,在线帐户,打印机,区域和语言面板等方面. 在网络面板中已经简化了忽略的网络接口类型,当 NMDevice 没有 hw 地址(硬件地址)时,它不会再崩溃.另一方面,在打印机面板中允许用户撤销删除的打印机,为打印机删除作业增加

iOS7应用开发6:UINavigation, UITabbar控制器的多态性

1.前期所实现的PlayingCard游戏,其View Controller只能适应PlayingCard这一种游戏规则.而将createDeck函数修改为返回一个nil后,整个View Controller与PlayingCard就没有关系了(同时也就没法运行了),成为了一种抽象的概念(类似于C++中的抽象类),实际的控制器必须派生这个类才能实现自身的功能. 新建一个View Controller类,并实现createDeck方法.此时build工程,无法正常运行.因为当前storyboard

定制UITabBar显示样式

定制UITabBar显示样式   思路是这样子的: 1. 初始化UITabBarController,并装载进来几个其他的ViewController 2. 获取每个控制器的UITabBarItem 3. 单独配置每个ViewController对应的UITabBarItem(其中,文字可以设置偏移量) 就这么简单哦!       问:如何设置UITabBarController高亮选中的颜色值呢?   问:[UITabBar appearance]能干什么? 他是进行UITabBarContr

WWDC 2013 Session笔记 - iOS7中的ViewController切换

这是我的WWDC2013系列笔记中的一篇,完整的笔记列表请参看这篇总览.本文仅作为个人记录使用,也欢迎在许可协议范围内转载或使用,但是还烦请保留原文链接,谢谢您的理解合作.如果您觉得本站对您能有帮助,您可以使用RSS或邮件方式订阅本站,这样您将能在第一时间获取本站信息. 本文涉及到的WWDC2013 Session有 Session 201 Building User Interfaces for iOS 7 Session 218 Custom Transitions Using View C

App升级iOS7体会

App升级iOS7体会 本文转自App升级iOS7体会. xcode5 GM版已经发布,虽然还是pre-release版,但离最终版不远了.对于没有用到新特性的app面临的最大问题就是UI的变化.Apple提供了UI Transition Guide给开发者,原本打算翻译一下,没想到国内早就有译文了(唉-看来NDA对于某些人而言,等于NULL). 鉴于此,这里侧重于Apple提供的cheklist以及app在升级过程中遇到的问题. 管窥全豹 扁平化的设计已经"流传"了很久,iOS7上标

ios7适配--uitableviewcell选中效果

ios7 UITableViewCell selectionStyle won't go back to blue up vote6down votefavorite 2 Xcode 5.0, iOS 7 and updating an existing app. UITableView selected row is now gray, not blue. From what I've read they changed the default selectionStyle to gray.

iOS7 中的新特性

iOS7 中的新特性 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 介绍 Introduction文档组织结构 Organization of This Document  iOS 7.0 用

Changing Tint / Background color of UITabBar

28 down vote favorite 46 share [fb] share [tw] The UINavigationBar and UISearchBar both have a tintColor property that allows you to change the tint color (surprising, I know) of both of those items. I want to do the same thing to the UITabBar in my