@interface HPTabBarController ()<UITabBarControllerDelegate>//继承自UITabBarController

@property (nonatomic, strong) HPMapViewController *mapViewController;
@property (nonatomic, strong) HPPGCListViewController *PGCListViewController;
@property (nonatomic, strong) HPLonelyShopViewController *lonelyShopVC;
@property (nonatomic, strong) HPPickerViewController *pickerViewController;
@property (nonatomic, strong) HPMessageListViewController *messageViewController;
@property (nonatomic, strong) HPProfileViewController *profileViewController;
@end @implementation HPTabBarController -(void)viewWillLayoutSubviews { // 修改Tabbar的高度
CGRect tabFrame =self.tabBar.frame;
CGFloat TABBAR_HEIGHT = + ;
tabFrame.size.height= TABBAR_HEIGHT;
tabFrame.origin.y= self.view.frame.size.height- TABBAR_HEIGHT;
self.tabBar.frame= tabFrame;
} - (void)viewDidLoad
{
[super viewDidLoad]; self.viewControllers = [self tabBarControllers];
UIView *topLine = [[UIView alloc]initWithFrame:CGRectMake(, , SCREEN_WIDTH, 0.5)];
topLine.backgroundColor = [UIColor clearColor];
[self.tabBar addSubview:topLine]; UIImage *bgClearImg = [UIImage imageWithColor:[UIColor colorWithRed:/255.0 green:/255.0 blue:/255.0 alpha:0.94/1.0]];
self.tabBar.backgroundImage = [UIImage imageNamed:@"shadows_@3x"];//bgClearImg; [self.tabBar.items enumerateObjectsUsingBlock:^(UITabBarItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (idx == ) { //修改tabbar的间距
[obj setImageInsets:UIEdgeInsetsMake(-, , -, -)];
}else if (idx == ) {
[obj setImageInsets:UIEdgeInsetsMake(, -, , )];
}
obj.tag = idx;
}];
self.selectedIndex = ;
}

效果:

iOS 修改TabBar的item间距的更多相关文章

  1. 关于修改tabbar的颜色的问题

    首先,项目是在故事板中搭建的,所以遇到这个问题的时候,首先是想到在故事板中找到相关的属性,确实是有一个Selected Image,但是设置了这个图片以后,运行的效果是,点击选择后,本身的image就 ...

  2. iOS 7 tabbar 透明的问题

    在某种特定情景中,ios的tabbar会出现完全透明的情况,出现这种情况的原因是ios7 默认的view因为IOS7默认是全延伸,也就是说controller是延伸到tabbar下面,并且在windo ...

  3. IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容

    IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容 UIAlertController *alertVC = [UIAlertController alertControl ...

  4. ios 修改导航条返回按钮

    ios 修改导航条返回按钮 方式一:使用系统的:可以更改系统的文字:以及通过设置导航条的颜色来达到预期的效果 UIBarButtonItem *backBtns = [[UIBarButtonItem ...

  5. 修改tabbar 字体颜色

    NSDictionary *seletedTextAttrs = @{NSForegroundColorAttributeName:[UIColor orangeColor]}; 修改tabbar 字 ...

  6. iOS 11 导航栏 item 偏移问题 和 Swift 下 UIButton 设置 title、image 显示问题

    html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...

  7. 微信小程序换皮肤,动态切换菜单栏和导航栏的样式,动态修改TabBar和NavigationBar

    在做微信小程序换皮肤的时候,需要动态修改菜单栏(TabBar)和导航栏(NavigationBar) 但是在小程序中它们的样式是写在app.json里面,而且app.json是静态编译,运行时哪怕你修 ...

  8. iOS UIButton文字和图片间距随意调整

    代码地址如下:http://www.demodashi.com/demo/11606.html 前记 在开发中,我们经常会遇到这么一种情况,就是一个按钮上面有图片也有文字,但是往往设计并不是我们想要的 ...

  9. iOS更改tabbar图片渲染 —不让tabbat有蓝色的渲染 并修改文字

    方式一  代码实现 这种要写很多代码 ,每个控制器都要写   UIImage *image=[UIImage imageNamed:@"tabBar_friendTrends_click_i ...

随机推荐

  1. pythn os

    获取文件所在路径 import os os.path.dirname(__file__)  获取当前文件的所在路径 print (os.path.dirname(os.path.dirname(__f ...

  2. Selenium Web 自动化 - 项目实战(二)

    Selenium Web 自动化 - 项目实战(二) 2016-08-08 什么是数据驱动?简答的理解就是测试数据决定了测试结果,这就是所谓数据驱动.数据驱动包含了数据,他就是测试数据,在自动化领域里 ...

  3. Msf提权步骤

    1.生成反弹木马(脚本,执行程序) msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=&l ...

  4. Android Launcher分析和修改2——Icon修改、界面布局调整、壁纸设置

    上一篇文章说了如何修改Android自带Launcher2的默认界面设置(http://www.cnblogs.com/mythou/p/3153880.html). 今天主要是说说Launcher里 ...

  5. Spring-boot初始化创建(一)

    Spring Boot 是什么 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人 ...

  6. hdoj:2028

    #include <iostream> using namespace std; int main() { int n, i; ]; while (cin >> n) { in ...

  7. Java知多少(103)网络编程之IP地址和InetAddress类

    Java语言的优势之一是Java程序能访问网络资源.Java提供一系列的类支持Java程序访问网络资源. TCP/IP协议和IP地址 为了进行网络通信,通信双方必须遵守通信协议.目前最广泛使用的是TC ...

  8. Rest风格理解

    之前一直不理解restful风格,今天终于理解了些(20170527) 正常我们在浏览器的地址栏中输入的地址很多都是发起的,发起的都是get请求 通过ajax可以设置put请求,F12查看浏览器请求头 ...

  9. 根据key删除Map集合中的key-value映射

    一:在遍历Map时是不可以删除key-value映射的,如果根据key删除,如下: public static void main(String[] args) { Map<String,Obj ...

  10. js 六种数据类型的区别及bool 转换判断

    一.bool型转换判断: 1.true 和 1 比较是相同,false 和 0 比较是相同(是 “==” 比较),因为内部会实现数据类型的 转化,将true 转换成1,将false 转换成0, js ...