Navigation Bar和TabBar的美化常用方法整理,后面会补充

在AppDelegate文件中实现的方法有:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

[self customNavigationBar];

[self customTabBar];

return YES;

}

//美化TabBar

-(void)customTabBar{

UIEdgeInsets standardEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);

// 整个tabBar的背景图

[[UITabBar appearance] setBackgroundImage:[[UIImage imageNamed:@"tabbar_back"] resizableImageWithCapInsets:standardEdgeInsets resizingMode:UIImageResizingModeStretch]];

//设置tab bar上每一个项被选中时的背景图

[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_selected_back"]];

//设置tab bar item上文字的位置 大小  颜色

[[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, -1)];

[[UITabBarItem appearance]setTitleTextAttributes:@{

NSForegroundColorAttributeName:[UIColor lightGrayColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:12]

} forState:UIControlStateNormal];

[[UITabBarItem appearance]setTitleTextAttributes:@{

NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:12]

} forState:UIControlStateSelected];

}

//美化导航栏

-(void)customNavigationBar{

//设置背景色

[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];

//设置有导航条时,状态栏的文字颜色

[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

//设置导航条的背景图

//[[UINavigationBar appearance] setBackgroundImage:[UIImage       imageNamed:@"NavigationBarDefault"] forBarMetrics:UIBarMetricsDefault];

//设置左右按钮上的文字颜色

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

//设置返回按钮中出现的箭头样式

[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"back_btn"]];

[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"back_btn"]];

//设置中间的title的文字样式

//设置阴影 颜色 偏移量

NSShadow *shadow = [[NSShadow alloc]init];

shadow.shadowColor = [UIColor redColor];

shadow.shadowOffset = CGSizeMake(0, 1);

NSDictionary *dictionary = [NSDictionary   dictionaryWithObjectsAndKeys:shadow,NSShadowAttributeName,[UIColor whiteColor],NSForegroundColorAttributeName,[UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21],NSFontAttributeName,nil];

[[UINavigationBar appearance] setTitleTextAttributes:dictionary];

}

//在控制器中要实现的方法有

- (id)initWithCoder:(NSCoder *)aDecoder{

self = [super initWithCoder:aDecoder];

if(self){

[self.navigationController.tabBarItem setImage:[UIImage imageNamed:@"tabbar_item_my_music"]];

[self.navigationController.tabBarItem setSelectedImage:[[UIImage imageNamed:@"tabbar_item_my_music_selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] ];

}

return self;

}

时间: 2024-10-07 02:00:51

Navigation Bar和TabBar的美化常用方法整理,后面会补充的相关文章

Navigation Bar 和 Status Bar 的设置

概念:所谓的UINavigationItem就可以理解为Navigation Bar中的内容,通过编辑UINavigationItem, 我们可以使得在Navigation Bar中显示想要的东西,比如设置标题.添加按钮 navigationItem和UINaviagationController平级, 1. navigationBar自己有很多属性:比如 barStyle .背景 backgroundColor .frame属性(可以获得宽高这些信息) 2. 可以通过setBackground

Status bar and navigation bar appear over my view's bounds in iOS 7

转自:http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7 Question: I recently downloaded Xcode 5 DP to test my apps in iOS 7. The first thing I noticed and confirmed is that my view's bounds is

UINavigationController出现nested push animation can result in corrupted navigation bar的错误提示

今天在测试过程中,出现了这样一个bug,分别有两种情景: (前提是:app是基于UINavigationController构建的) 1.从Controller-A中push进来B.在B中点击返回,返回的界面为黑色一片.再做返回操作就crash了. 如图1: 2.从Controller-A中push进入B,此时B中tableview出现错位现象(图2),tableview被navigationbar覆盖了一部分,在B中再push一个C进来.此时只显示了C的navigationbar,但下方的vi

配置navigation bar外观

/* 配置navigation bar外观开始 */ self.navigationBar.translucent = YES; self.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; self.navigationBar.tintColor = [UIColor whiteCol

Android判断Navigation Bar 是否透明

设置Navigation Bar 透明 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 或者Theme中添加  <item name="android:windowTranslucentNavigation">true</item> /** * Convenience function to set the flag bits as specified i

用swift实现navigation bar的完全透明 &amp; navigation bar中button的字体大小调整

这几天在项目中遇到的关于navigation bar的一些小问题以及解决的方法记录一下吧: 1.  完全透明navigation bar 有时候我们想要navigation viewcontroller顶部的navigation bar变得完全透明,我们首先想到是从story board下手,但是尝试了半天,也不能达到完全透明的效果 选择这里的Translucent Navigation Bar只能让bar变成那种可以稀释背景色的毛玻璃的效果,那么究竟应该如何才能把整个navigation ba

与Status Bar和Navigation Bar相关的一些东西

与StatusBar和NavigationBar相关的东西有两种,一是控制它们的显示与隐藏,二是控制它们的透明与否及背景. 在2.3及以前,StatusBar只能显示与隐藏,即全屏模式,通过WindowManager.LayoutParams.FLAG_FULLSCREEN来实现: getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 并可通过以下Flag使Activity的布局可以使用整个屏幕,状态栏会显示到Acti

Objective-C 几何类常用方法整理

Objective-C  几何类常用方法整理 CGGeometry参考定义几何结构和功能,操作简单.数据结构中的一个点CGPoint代表在一个二维坐标系统.数据结构的位置和尺寸CGRect代表的一个长方形.数据结构的尺寸CGSize代表宽度和高度. 1.创建一个几何原始数值    CGPoint  CGPointMake(CGPoint A,CGPoint B) 返回一个指定坐标点 CGRect   CGRectMake(CGFloat x,CGFloat y,CGFloat width,CGF

nested push animation can result in corrupted navigation bar

2014-07-05 17:11:20.594 SevenStars[2185:60b] nested push animation can result in corrupted navigation bar 2014-07-05 17:11:21.005 SevenStars[2185:60b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get