TabBarController

创建窗口
self.window=[[UIWindow alloc]init];
self.window.frame=[UIScreen MainScreen].bounds;
self.window.rootViewController=tabBarVc;//设置根控制器
[self.window makeKeyAndVisible];
 
设置根控制器
UITabBarController *tabBarVc=[[UITabBarController alloc]init];

UITableViewController *vc1=[[UITableViewController alloc]init];

vc1.view.backgroundColor=[UIColor redColor];
vc1.Item.title=@“”;
vc1.Item.image=[UIImage imageNamed:@“”];
 [tabBarVc addChildViewController:vc1];
//设置普通状态下的文字属性
NSMutableDictionary *normalAttrs=[NSMutableDictionary dictionary];
normalAttrs[NSFontAttributeName]=[UIFont systemFontSize:20];
normalAttrs[NSForegroundColorAttributeName]=[UIColor redColor];
[vc1.tabBarItem setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
//设置选中状态文字属性
NSMutableDictionary *selectedAttrs=[NSMutableDictionary dictionary];
selectedAttrs[NSForegroundColorAttributeName]=[UIColor orangeColor];
selectedAttrs[NSFontAttributeName]=[UIFont systemFontSize:20];
[vc1.tabBarItem setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
 

//文字属性- 通过UITabBarItem的appearance对象统一设置

    UITabBarItem *item=[UITabBarItem appearance];

    

    //设置普通状态下的文字属性

    NSMutableDictionary *normalAttrs=[NSMutableDictionary dictionary];

    normalAttrs[NSFontAttributeName]=[UIFont systemFontOfSize:14];

    normalAttrs[NSForegroundColorAttributeName]=[UIColor darkGrayColor];

    [item setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];

 

    //设置选中状态下的文字属性

    NSMutableDictionary *selectedAttrs=[NSMutableDictionary dictionary];

    selectedAttrs[NSForegroundColorAttributeName]=[UIColor grayColor];

    selectedAttrs[NSFontAttributeName]=[UIFont systemFontOfSize:16];

    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];

设置TabBar图片属性
 
1.取消图片渲染颜色
UIImage *img=[[UIImage imageNamed:@“”]imageWithRenderingMode:UIImageRenderingModelAlwaysOriginal];
vc1.tabBarItem.selectedImage=img;// 设置tabBarItem的选中图片
 
2.设置UIButtonTypeSystem样式按钮的image时
UIButton *btn=[[UIButton buttonWithType:UIButtonTypeSystem];
[btn setImage:image forState:UIControlStateNormal];
 

项目图片资源可以利用一个MAC软件解压 https://github.com/devcxm/iOS-Images-Extractor

随机数生成

CGFloat i=arc4random_uniform(100)/100.0;

转载于:https://www.cnblogs.com/finker/p/6102937.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值