UINavigationController以及UITabBarController背景图片和文字的设置
2016-01-04 13:12
423 查看
系统版本大于7.0以后,再用到在iOS
7中,苹果引入了一个新的属性,叫做
controller时,默认的布局将从navigation bar的顶部开始。这就是为什么所有的UI元素都往上漂移了44pt。
if (OSVersionIsAtLeastiOS7()) {
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout = UIRectEdgeNone;
}
}
//修改tabbarItem的字体颜色
[[UITabBarItem
appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor
grayColor],
NSFontAttributeName:[UIFont
systemFontOfSize:10]
}
forState:UIControlStateNormal];
[[UITabBarItem
appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor
redColor],
NSFontAttributeName:[UIFont
systemFontOfSize:10]}
forState:UIControlStateSelected];
//设置tabbar背景图片
[[UITabBar
appearance] setBackgroundImage:[UIImage
imageNamed:@"sixin_bottom_bg"]];
//去除tabbar在iOS7显示的时候在顶部出现的黑线
[[UITabBar
appearance] setShadowImage:[[UIImage
alloc] init]];
//导航栏字体设置
self.navigationBar.titleTextAttributes =
@{
NSFontAttributeName: [UIFont
boldSystemFontOfSize:20.0],
NSForegroundColorAttributeName: [UIColor
colorWithHexString:@"#2c2c2b"],
};
//导航栏返回按钮颜色
self.navigationBar.tintColor =
SBTextColor;
//market_returns_icon@2x
//navigationBar的背景颜色
self.navigationBar.barTintColor = [UIColor
whiteColor];
//导航栏背景
[[UINavigationBar
appearance] setBackgroundImage:[UIImage
createImageWithColor:[UIColor
whiteColor]] forBarMetrics:UIBarMetricsDefault];
/**
* 电池栏颜色修改 info.plist
里面
添加 View controller-based status bar appearance = NO
*/
[[UIApplication
sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];//状态栏颜色
}
}
7中,苹果引入了一个新的属性,叫做
[UIViewController setEdgesForExtendedLayout:],它的默认值为
UIRectEdgeAll。当你的容器是navigation
controller时,默认的布局将从navigation bar的顶部开始。这就是为什么所有的UI元素都往上漂移了44pt。
if (OSVersionIsAtLeastiOS7()) {
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout = UIRectEdgeNone;
}
}
//修改tabbarItem的字体颜色
[[UITabBarItem
appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor
grayColor],
NSFontAttributeName:[UIFont
systemFontOfSize:10]
}
forState:UIControlStateNormal];
[[UITabBarItem
appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor
redColor],
NSFontAttributeName:[UIFont
systemFontOfSize:10]}
forState:UIControlStateSelected];
//设置tabbar背景图片
[[UITabBar
appearance] setBackgroundImage:[UIImage
imageNamed:@"sixin_bottom_bg"]];
//去除tabbar在iOS7显示的时候在顶部出现的黑线
[[UITabBar
appearance] setShadowImage:[[UIImage
alloc] init]];
//导航栏字体设置
self.navigationBar.titleTextAttributes =
@{
NSFontAttributeName: [UIFont
boldSystemFontOfSize:20.0],
NSForegroundColorAttributeName: [UIColor
colorWithHexString:@"#2c2c2b"],
};
//导航栏返回按钮颜色
self.navigationBar.tintColor =
SBTextColor;
//market_returns_icon@2x
//navigationBar的背景颜色
self.navigationBar.barTintColor = [UIColor
whiteColor];
//导航栏背景
[[UINavigationBar
appearance] setBackgroundImage:[UIImage
createImageWithColor:[UIColor
whiteColor]] forBarMetrics:UIBarMetricsDefault];
/**
* 电池栏颜色修改 info.plist
里面
添加 View controller-based status bar appearance = NO
*/
[[UIApplication
sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];//状态栏颜色
}
}
相关文章推荐
- UINavigationController
- UINavigationControll采用pushViewController后如何去掉左边的返回按钮
- UINavgationBar之UIBarButtonItem
- Foundation 心得、笔记
- UINavigationController总结
- 给UITabbarController 和 UINavigationController添加过场动画
- iOS开发中遇到的一些问题以及解决办法总结
- UI_NavigationController
- swift下如何配置引导页后跳转rootViewController
- UINavigationController使用简介
- OC笔记 - 控制器管理、UINavigationController、segue、控制器的数据传递(2015.3.16)
- NavigationController单个界面横屏,其他全竖屏
- 控制器跳转
- IOS UINavigationController 中添加UITabBarItem
- 重写导航控制器,利用重写pop和push方法来隐藏底层的tabbar和其他一些事件
- 解决UINavigationController自定义返回键后没有侧滑返回效果的问题
- iOS--导航栏属性设置的介绍
- iOS开发系列--视图切换
- 多控制器
- UINavigationController 改变返回按钮标题