工作生活

UITabBarItme、UINavigationItem常见操

2019-07-04  本文已影响0人  独孤流
一、UITabBarItem

1.1、设置图片及文字相关的位移

vc.tabBarItem.imageInsets=UIEdgeInsetsMake(-5,0,5,0);
vc.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -5);

1.2、设置图片保留图片的颜色

UIImage *originImg = [UIImage imageNamed:[NSString stringWithFormat:@"xxx",iconName]];
UIImage *selectImg = [originImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc.tabBarItem.selectedImage = selectImg;

1.3、设置Item的字体及颜色

 //Normal
 [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:xxx} forState:UIControlStateNormal];
 //Selected
 [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:xxxx} forState:UIControlStateSelected];
二、UINavigationBar

2.1 去掉导航栏下面的阴影线

// 设置背景色
 [navigationBar setBackgroundImage:[UIImage xxxx]] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
// 设置阴影为空的图片
    [navigationBar setShadowImage:[UIImage new]];
上一篇 下一篇

猜你喜欢

热点阅读