1.语音识别
苹果官方在文档中新增了API Speech,那么在以前我们处理语音识别非常的繁琐甚至很多时候可能需要借助于第三方框架处理,那么苹果推出了这个后,我们以后处理起来就非常的方便了,speech具有以下特点:
可以实现连续的语音识别
可以对语 音文件或者语音流进行识别
最佳化自由格式的听写(可理解为多语言支持)和搜索式的字符串
官方文档:


核心代码:
- #import
-
- NSLocale *local =[[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
-
- SFSpeechRecognizer *sf =[[SFSpeechRecognizer alloc] initWithLocale:local];
-
-
-
- NSURL *url =[[NSBundle mainBundle] URLForResource:@"游子吟.mp3" withExtension:nil];
-
- SFSpeechURLRecognitionRequest *res =[[SFSpeechURLRecognitionRequest alloc] initWithURL:url];
-
-
- [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之后我们可以轻松个性化定制了。
核心代码:
-
-
- OneViewController *oneVc =[[OneViewController alloc] init];
-
-
- 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 = @"社交";
-
-
-
-
- [self addChildViewController:oneVc];
-
- [self addChildViewController:twovC];
- [self addChildViewController:threVC];
-
-
-
-
-
- oneVc.tabBarController.tabBar.tintColor =[UIColor yellowColor];
-
- twovC.tabBarController.tabBar.tintColor =[UIColor yellowColor];
-
- threVC.tabBarController.tabBar.tintColor =[UIColor yellowColor];
-
-
-
-
-
-
- oneVc.tabBarController.tabBar.unselectedItemTintColor =[UIColor redColor];
-
-
-
-
-
- oneVc.tabBarItem.badgeColor =[UIColor orangeColor];
- oneVc.tabBarItem.badgeValue =@"90";
-
-
- [oneVc.tabBarItem setBadgeTextAttributes:@{
- NSForegroundColorAttributeName:[UIColor blackColor]
- } forState:UIControlStateNormal];
3.iOS10.0中字体跟随系统设置变化大小
在以前如果说我们想改变APP中程序的字体大小,我们只能自定义字体或者使用runtime进行处理,或者都得设置UIFont,非常的不妨百年,从iOS 10苹果官方允许我们自定义设置
核心代码:
-
-
-
- [super viewDidLoad];
-
-
- self.labels.font =[UIFont preferredFontForTextStyle:UIFontTextStyleBody];
-
-
-
-
-
-
-
- self.labels.adjustsFontForContentSizeCategory = YES;
4.UIViewPropertyAnimator属性动画器
那么在iOS 10之前,我们使用UIView 做动画效果或者自定义一些layer 的动画,如果开始了,一般无法进行停止操作更不能暂停操作,而且一些非常复杂的动画处理也比较麻烦,但是在iOS10,苹果退出了一个全新的APIUIViewPropertyAnimator,可供我们处理动画操作
UIViewPropertyAnimator 是 iOS 10 中新增的一个执行 View 动画的类,具有以下特点:
可中断性
可擦除
可反转性
丰富的动画时间控制功能
官方文档:


核心代码:
- #import "ViewController.h"
- @interface ViewController ()
- @property(nonatomic,strong)UIView *myView;
- @property(nonatomic,strong)UIViewPropertyAnimator *myViewPro;
- @end
- @implementation ViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
-
- UIView *Views =[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
- Views.backgroundColor =[UIColor yellowColor];
- [self.view addSubview:Views];
-
-
- self.myView = Views;
-
-
-
- UIViewPropertyAnimator *viewPro =[UIViewPropertyAnimator runningPropertyAnimatorWithDuration:1.0 delay:30.0 options:UIViewAnimationOptionCurveLinear animations:^{
-
- self.myView.frame = CGRectMake(230, 230, 130, 130);
- } completion:nil];
-
- self.myViewPro = viewPro;
- }
-
- - (IBAction)stop:(id)sender {
-
-
- [self.myViewPro stopAnimation:YES];
- }
-
- - (IBAction)continued:(id)sender {
-
-
-
-
-
-
-
-
-
-
-
- UISpringTimingParameters *sp =[[UISpringTimingParameters alloc] initWithDampingRatio:0.01];
-
-
-
-
-
- [self.myViewPro continueAnimationWithTimingParameters:sp durationFactor:1.0];
- }
-
- - (IBAction)puase:(id)sender {
-
- [self.myViewPro pauseAnimation];
- }
-
- - (IBAction)start:(id)sender {
-
- [self.myViewPro startAnimation];
- }
5.UIColor 新增方法
在iOS10之前,UIColor中设置颜色只能通过RGB 来表示,在iOS原生还不支持#16进制写法,还得自己写分类去处理,我们知道RGB表示的颜色是优先的,而且也是不精准的,那么在iOS10中,苹果官方新增了colorWithDisplayP3Red方法
核心代码:
- + (
- UIColor
- *)colorWithDisplayP3Red:(
- CGFloat
- )displayP3Red green:(
- CGFloat
- )green blue:(
- CGFloat
- )blue alpha:(
- CGFloat
- )alpha
- NS_AVAILABLE_<a target="_blank" href="http://www.2cto.com/kf/yidong/iphone/" class="keylink" style="border:none; padding:0px; margin:0px; color:rgb(51,51,51); text-decoration:none; font-size:14px">IOS</a>
- (
- 10
- _0);
6.UIApplication对象中openUrl被废弃
在iOS 10.0以前的年代,我们要想使用应用程序去打开一个网页或者进行跳转,直接使用[[UIApplication sharedApplication] openURL 方法就可以了,但是在iOS 10 已经被废弃了,因为使用这种方式,处理的结果我们不能拦截到也不能获取到,对于开发是非常不利的,在iOS 10全新的退出了 [[UIApplication sharedApplication] openURL:nil options:nil completionHandler:nil];有一个成功的回调block 可以进行监视。
苹果官方解释:
关键代码:
- [[UIApplication sharedApplication] openURL:nil options:nil completionHandler:^(BOOL success) {
-
- }];
当然除了以上的这些,其它的还有很多,比如下面这些
6.SiriKit
在 iOS 10 里面开发者可以使用 Siri SDK,毫无疑问这也是 iOS 10 最重要的 SDK。从此开发者可以使用原生API提供语音搜索、语音转文字消息甚至更多常见语音功能。
7. User Notifications
这个 API 让你可以处理本地或远程的用户通知,并且可以基于某个条件,例如时间或者地理位置。这个异常强大,貌似可以拦截并替换自己 app 发下来的 payload,并且在之前版本SDK的本地通知框架已经被废弃了,在上一篇帖子有所讲到以及代码都有展示。
8.CallKit
继2014年苹果推出VoIP证书后,这次VoIP 接口的开放,以及一个全新的 App Extension,简直是VOIP的福音,可见苹果对VOIP的重视。callkit框架 VoIP应用程序集成与iPhone的用户界面,给用户一个很棒的经历。用这个框架来让用户查看和接听电话的锁屏和VoIP管理联系人电话在手机APP的收藏夹和历史的观点。
callkit还介绍了应用程序的扩展,使呼叫阻塞和来电识别。您可以创建一个应用程序扩展,可以将一个电话号码与一个名称联系起来,或者告诉系统当一个号码应该被阻止。
9.第三方键盘的改进
非常非常重要,第三方键盘一直都不能很方便的拥有长按地球键的功能,现在有了。通过 handleInputModeListFromView:withEvent: 可以弹出系统键盘列表。同时使用 documentInputMode 可以检测输入上下文中的语言,你可以对输入方式进行一些类似于对齐方式的调整。
10.iOS10 对隐私权限的管理
比如访问的摄像头、麦克风等硬件,都需要提前请求应用权限、允许后才可以使用,或者现在要提前声明,虽然以往要求不严格。在iOS10中比如遇到崩溃,日志:
崩溃日志:
***This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescriptionkey with a string value explaining to the user how the app uses this data.
你需要在info.plist文件 添加一个“NSContactsUsageDescription”的Key,Value添加一个描述。
视频播放 需要在info.Plist中配置
官方解释:This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSAppleMusicUsageDescription key with a string value explaining to the user how the app uses this data.
访问用户的隐私数据,并且没有向用户说明,必须在plist(info.plist)中配置这个key NSAppleMusicUsageDescription 并且向用户说明.
11.Xcode7 和Xcode 8项目中的xib兼容问题
在Xcode8上打开项目要小心,尤其是对于xib过程,在变动后可不要随意点保存,否则当你回头用Xcode7打开时时发现报错了,Xcode保存的xib在xcode7上是识别不了的!
12.APPlePlay(苹果支付)
可用于 SFSafariViewController
可用于没有UI的extensions中
在 iMessage 应用中也支持 ApplePay
13.CoreData提升了并发访问性能
14.刷新控件(UIRefresh Control)
iOS系统自带的刷新控件支持所有的 UIScrollView 以及其子类,比如说 UICollectionView,UITableView。
核心代码:
-
-
-
-
-
-
- #import
- @class UIRefreshControl;
- NS_CLASS_AVAILABLE_IOS(10_0) @protocol UIRefreshControlHosting
- @property (nonatomic, strong, nullable) UIRefreshControl *refreshControl __TVOS_PROHIBITED;
- @end
15.GCD多线程支持创建私有队列