iOS开发项目之三 [ 自定义tabBarCtrl]

时间:2023-03-09 05:00:05
iOS开发项目之三 [ 自定义tabBarCtrl]

01

让tabBar的图片保持原样.图片渲染的处理

ctrl.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

02

//给底部的标题设置颜色

//初始化一个文字属性字典 把文字属性字典添加

NSMutableDictionary *Mdic = [NSMutableDictionary dictionary];

Mdic[NSForegroundColorAttributeName] = [UIColor orangeColor];

[ctrl.tabBarItem setTitleTextAttributes:Mdic forState:UIControlStateSelected];

03 设置tabBar图片的偏移量

//设置图片的偏移量

ctrl.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);