博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ios7 - Custom UItabbar has a gap in the bottom
阅读量:5992 次
发布时间:2019-06-20

本文共 2078 字,大约阅读时间需要 6 分钟。

 

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

|
|
 
   
   
how high Tabbar_on_01? –    
   
   
the @2x image is 128x100px I also tried with 128x98px and got the same problem. –    
 
   
   
Is your view designed with Interface Builder, or do you create it programmatically? –    
   
   
programmatically zbMax –    
   
   
Can you edit your question and add the code creating the tabbar please? By the way, follow this guidelines page for your icon dimension :  –  
   
 

1 Answer

1

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);
|
|
欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 572064792 | Nodejs:329118122 做人要厚道,转载请注明出处!
本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sunshine-anycall/p/3449372.html
,如需转载请自行联系原作者
你可能感兴趣的文章
访问网站出现 Directory Listing Denied This Virtual Directory
查看>>
用C语言解决迷宫问题
查看>>
Android中通过反射来设置Toast的显示时间
查看>>
Vysor Pro破解助手
查看>>
翻译Beginning iOS 7 Development中文版
查看>>
JavaSE学习总结(八)—— 异常处理(Exception)
查看>>
理顺FFT
查看>>
003-spring结合java类调用quartz
查看>>
Idea 常用功能汇总,工作中常用技巧,移出请说明原因,笔记花了好长时间汇总的...
查看>>
php给图片加入文字水印
查看>>
iOS开发-sqlite3使用
查看>>
(5)QlikView中的RowNo()函数
查看>>
SiteMesh2-示例工程
查看>>
poj 1087 A Plug for UNIX 【最大流】
查看>>
Phoenix与Squirrel 是什么?
查看>>
Photoshop制作的ico图标方法
查看>>
HDU 1241 Oil Deposits (DFS)
查看>>
【翻译自mos文章】注意: ASMB process exiting due to lack of ASM file activity
查看>>
Linux 线程浅析
查看>>
ucgui界面设计演示样例2
查看>>