iOS开发--一些UITabBarItem属性的设置
2017-10-18 10:18
381 查看
1.改变UITabBarItem 字体颜色
[[UITabBarItemappearance]setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColorwhiteColor],UITextAttributeTextColor,nil]forState:UIControlStateNormal];
[[UITabBarItemappearance]setTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:[UIColorcolorWithHexString:"#00C8D3"],UITextAttributeTextColor,nil]forState:UIControlStateSelected];
设置tabbarItem选中的颜色为红色
2.改变UITabBarItem 字体颜色和大小
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"Helvetica" size:12.0f],NSFontAttributeName,nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"Helvetica" size:12.0f],NSFontAttributeName,nil] forState:UIControlStateSelected];
设置UITabBarItem 字体颜色和大小
这里需要注意的是在设置字体的时候要选择支持中文的字体,不然的话修改字号是无效的,比如字体设置成“ProximaNova-Semibold”,这种字体本身只支持英语的,不支持中文所以使用该字体并不能调整字体大小
3.改变UITabBarItem的选中和非选中图片
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:[[ServiceProviderViewController alloc] init]];
nav1.tabBarItem.image = [ImageNamed(@"tabicon1_unselect") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
nav1.tabBarItem.selectedImage = [ImageNamed(@"tabicon1_select") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
nav1.tabBarItem.title = @"服务商";
改变UITabBarItem的选中和非选中图片
4.改变UITabBarController的颜色
UIView*mView=[[UIViewalloc]initWithFrame:CGRectMake(0,0,320,48)];//这是整个tabbar的颜色
[mViewsetBackgroundColor:[UIColorcolorWithPatternImage:[UIImageimageNamed:@"tabbar.png"]]];
[tab.tabBarinsertSubview:mViewatIndex:1];
mView.alpha=0.8;
设置UITabBar的颜色
5.如何隐藏系统自带的tabbar
有时候有的页面并不需要显示tabbar,但是返回的时候要显示tabbar,举个例子A->B 当A push到 B 时需要设置self.navigationController.hidesBottomBarWhenPushed= YES;
A页面的设置
同时在B页面要
- (void)viewWillAppear:(BOOL)animated
{
[superviewWillAppear:animated];
self.tabBarController.tabBar.hidden=YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
[superviewWillDisappear:animated];
self.tabBarController.tabBar.hidden=NO;
}
作者:寒桥
链接:http://www.jianshu.com/p/a4acb98618b4
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
[[UITabBarItemappearance]setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColorwhiteColor],UITextAttributeTextColor,nil]forState:UIControlStateNormal];
[[UITabBarItemappearance]setTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:[UIColorcolorWithHexString:"#00C8D3"],UITextAttributeTextColor,nil]forState:UIControlStateSelected];
设置tabbarItem选中的颜色为红色
2.改变UITabBarItem 字体颜色和大小
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"Helvetica" size:12.0f],NSFontAttributeName,nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"Helvetica" size:12.0f],NSFontAttributeName,nil] forState:UIControlStateSelected];
设置UITabBarItem 字体颜色和大小
这里需要注意的是在设置字体的时候要选择支持中文的字体,不然的话修改字号是无效的,比如字体设置成“ProximaNova-Semibold”,这种字体本身只支持英语的,不支持中文所以使用该字体并不能调整字体大小
3.改变UITabBarItem的选中和非选中图片
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:[[ServiceProviderViewController alloc] init]];
nav1.tabBarItem.image = [ImageNamed(@"tabicon1_unselect") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
nav1.tabBarItem.selectedImage = [ImageNamed(@"tabicon1_select") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
nav1.tabBarItem.title = @"服务商";
改变UITabBarItem的选中和非选中图片
4.改变UITabBarController的颜色
UIView*mView=[[UIViewalloc]initWithFrame:CGRectMake(0,0,320,48)];//这是整个tabbar的颜色
[mViewsetBackgroundColor:[UIColorcolorWithPatternImage:[UIImageimageNamed:@"tabbar.png"]]];
[tab.tabBarinsertSubview:mViewatIndex:1];
mView.alpha=0.8;
设置UITabBar的颜色
5.如何隐藏系统自带的tabbar
有时候有的页面并不需要显示tabbar,但是返回的时候要显示tabbar,举个例子A->B 当A push到 B 时需要设置self.navigationController.hidesBottomBarWhenPushed= YES;
A页面的设置
同时在B页面要
- (void)viewWillAppear:(BOOL)animated
{
[superviewWillAppear:animated];
self.tabBarController.tabBar.hidden=YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
[superviewWillDisappear:animated];
self.tabBarController.tabBar.hidden=NO;
}
作者:寒桥
链接:http://www.jianshu.com/p/a4acb98618b4
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
相关文章推荐
- iOS开发--一些UITabBarItem属性的设置[转]
- iOS开发设置关于tabBar和navigationBar以及item中的一些全局属性
- iOS开发--一些UINavigationBar属性的设置
- 关于一些iOS开发中容易忽略的一些属性设置
- iOS开发- UITabBarController的TabBar、TabBarItem背景颜色设置
- iOS开发--一些UINavigationBar属性的设置
- ios 开发中,如何设置 uitabbar 里面 tabbaritem 不显示文字,只显示图片,图片垂直居中?
- iOS切圆角的方式 第一种方法:通过设置layer的属性 最简单的一种,但是很影响性能,一般在正常的开发中使用很少. UIImageView *imageView = [[UIImag
- iOS开发 automaticallyAdjustsScrollViewInsets 属性设置
- iOS开发UITabBarController设置选中图片
- iOS开发之Swift标签栏按钮UITabBarItem样式修改(图标文字尺寸,颜色等)
- 【iOS开发】设置TabBarItem上文字跟图片一样的颜色
- ios app开发属性设置基础教程
- ios 开发的一些控件综合属性总结
- 【iOS开发】ScrollView的一些常用属性
- IOS开发中设置控件内容对齐方式时容易混淆的几个属性
- iOS开发 - 详谈属性设置readwrite、readonly、retain、copy、assign、nonatomic
- iOS开发之UITextField常用属性设置
- C Sharp 开发自定义控件时,对属性事件等的一些描述与设置
- iOS开发笔记--UILabel的相关属性设置