iOS 修改TabBar的item间距
@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间距的更多相关文章
- 关于修改tabbar的颜色的问题
首先,项目是在故事板中搭建的,所以遇到这个问题的时候,首先是想到在故事板中找到相关的属性,确实是有一个Selected Image,但是设置了这个图片以后,运行的效果是,点击选择后,本身的image就 ...
- iOS 7 tabbar 透明的问题
在某种特定情景中,ios的tabbar会出现完全透明的情况,出现这种情况的原因是ios7 默认的view因为IOS7默认是全延伸,也就是说controller是延伸到tabbar下面,并且在windo ...
- IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容
IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容 UIAlertController *alertVC = [UIAlertController alertControl ...
- ios 修改导航条返回按钮
ios 修改导航条返回按钮 方式一:使用系统的:可以更改系统的文字:以及通过设置导航条的颜色来达到预期的效果 UIBarButtonItem *backBtns = [[UIBarButtonItem ...
- 修改tabbar 字体颜色
NSDictionary *seletedTextAttrs = @{NSForegroundColorAttributeName:[UIColor orangeColor]}; 修改tabbar 字 ...
- 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 ...
- 微信小程序换皮肤,动态切换菜单栏和导航栏的样式,动态修改TabBar和NavigationBar
在做微信小程序换皮肤的时候,需要动态修改菜单栏(TabBar)和导航栏(NavigationBar) 但是在小程序中它们的样式是写在app.json里面,而且app.json是静态编译,运行时哪怕你修 ...
- iOS UIButton文字和图片间距随意调整
代码地址如下:http://www.demodashi.com/demo/11606.html 前记 在开发中,我们经常会遇到这么一种情况,就是一个按钮上面有图片也有文字,但是往往设计并不是我们想要的 ...
- iOS更改tabbar图片渲染 —不让tabbat有蓝色的渲染 并修改文字
方式一 代码实现 这种要写很多代码 ,每个控制器都要写 UIImage *image=[UIImage imageNamed:@"tabBar_friendTrends_click_i ...
随机推荐
- CSA Enterprise Architecture图
https://research.cloudsecurityalliance.org/tci/index.php/explore/
- [Big Data - Suro] Netflix开源数据流管理器Suro
Netflix近日开源了一个叫做Suro的工具,公司可以利用它来做数据源主机到目标主机的实时定向.它不只在Netflix的数据管道上扮演重要角色,大规模下的应用场景同样令人印象深刻. Netflix各 ...
- 阅读《深入应用C++11:代码优化与工程级应用》
虽然一直是写C++的,但是却对C++11了解的不是太多,于是从图书馆借了本书来看 这本书分两大部分: 一.C++11的新特性讲解 二.工程级代码中C++11的应用 这样的安排很合理,第一部分把新特性讲 ...
- Android Launcher分析和修改2——Icon修改、界面布局调整、壁纸设置
上一篇文章说了如何修改Android自带Launcher2的默认界面设置(http://www.cnblogs.com/mythou/p/3153880.html). 今天主要是说说Launcher里 ...
- stm32之TIM+ADC+DMA采集50HZ交流信号
http://cache.baiducontent.com/c?m=9d78d513d98207f04fece47f0d01d7174a02d1743ca6c76409c3e03984145b5637 ...
- oneinstack 另一个 lnmp环境一键安装工具
oneinstack 另一个 http://oneinstack.com/ OneinStack包含以下组合: lnmp(Linux + Nginx+ MySQL+ PHP) lamp(Linux ...
- Ubuntu16.04安装xgboost
1.Python下安装方法 git clone --recursive https://github.com/dmlc/xgboost cd xgboost make -j4 cd python-pa ...
- Oracle relink 重新编译
如此而已! export ORACLE_HOME=/opt/oracle/11.2 export LD_LIBRARY_PATH=/lib:/lib64:$ORACLE_HOME/lib:$ORACL ...
- GoLang之strings、buffers、bytes、binary包
strings包 strings包的使用举例: package main import s "strings" import "fmt" var p = fmt ...
- 为你的mail server增加SPF记录
什么是SPF就是Sender Policy Framework.SPF可以防止别人伪造你来发邮件,是一个反伪造性邮件的解决方案.当你定义了你的domain name的SPF记录之后,接收邮件方会根据你 ...