iOS 10 开发这次更新主要表现在以下这几个方面。
1.语音识别
苹果官方在文档中新增了API Speech,那么在以前我们处理语音识别非常的繁琐甚至很多时候可能需要借助于第三方框架处理,那么苹果推出了这个后,我们以后处理起来就非常的方便了,speech具有以下特点:
可以实现连续的语音识别
可以对语 音文件或者语音流进行识别
最佳化自由格式的听写(可理解为多语言支持)和搜索式的字符串
核心代码:
#import <Speech/Speech.h>
/** 语音识别同样的需要真机进行测试 ,因为需要硬件的支持,还需要访问权限 */
//1.创建本地化标识符
NSLocale *local =[[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
//2.创建一个语音识别对象
SFSpeechRecognizer *sf =[[SFSpeechRecognizer alloc] initWithLocale:local];
//3.将bundle 中的资源文件加载出来返回一个url
NSURL *url =[[NSBundle mainBundle] URLForResource:@"太想爱你(张信哲)mp3" withExtension:nil];
//4.将资源包中获取的url 传递给 request 对象
SFSpeechURLRecognitionRequest *res =[[SFSpeechURLRecognitionRequest alloc] initWithURL:url];
//5.发送一个请求
[sf recognitionTaskWithRequest:res resultHandler:^(SFSpeechRecognitionResult * _Nullable result, NSError * _Nullable error) {
if (error!=nil) {
NSLog(@"语音识别解析失败,%@",error); }else{//解析正确NSLog(@"---%@",result.bestTranscription.formattedString);
}
}];
2.UITabBarController 中的改进
在iOS 10之前,tabBarItem上的文字颜色,默认是 蓝色,上面的新消息提醒数字badge 默认是红色的,未选中的TabBarItem的文字颜色默认是黑色的,我们修改的话,也只能修改它的默认颜色 ,其它的就不能进行个性化定制,使用起来非常的不方便,iOS10之后我们可以轻松个性化定制了。
核心代码:
//1.创建出三个UIViewcontroller 对象
OneViewController *oneVc =[[OneViewController alloc] init];
//2.设置每一个控制器上的
tabbar oneVc.view.backgroundColor =[UIColor redColor];
//设置标题
oneVc.tabBarItem.title = @"首页";
TwoViewController *twovC =[[TwoViewController alloc] init]; twovC.view.backgroundColor =[UIColor purpleColor];
//设置标题 twovC.tabBarItem.title = @"圈子";
ThreeViewController *threVC =[[ThreeViewController alloc] init];
threVC.view.backgroundColor =[UIColor blueColor];
//设置标题 threVC.tabBarItem.title = @"社交";
//2.将创建好的三个普通控制器加入到tabbarController 控制器中
[self addChildViewController:oneVc];
[self addChildViewController:twovC];
[self addChildViewController:threVC];
//改变tabbar 上面的文字默认颜色 oneVc.tabBarController.tabBar.tintColor =[UIColor yellowColor];
twovC.tabBarController.tabBar.tintColor =[UIColor yellowColor];
threVC.tabBarController.tabBar.tintColor =[UIColor yellowColor]; //使用iOS 10新推出的 修改 tabbar 未选中的tintColor 颜色
//这一句代码将 tabbar 未选中的时候的默认色- 黑色改为红色
oneVc.tabBarController.tabBar.unselectedItemTintColor =[UIColor redColor];
//tabbarItem 中属性
//数字提醒的颜色 在iOS 10之前的版本默认都是数字提醒都是红色 oneVc.tabBarItem.badgeColor =[UIColor orangeColor]; oneVc.tabBarItem.badgeValue =@"90";
//将tabBarItem 中数字提醒默认的白色改掉 使用富文本修改
[oneVc.tabBarItem setBadgeTextAttributes:@{ NSForegroundColorAttributeName:[UIColor blackColor] } forState:UIControlStateNormal];










