1.語音識別? ? ? 蘋果官方在文檔中新增了API? Speech,那么在以前我們處理語音識別非常的繁瑣甚至很多時候可能需要借助于第三方框架處理,那么蘋果推出了這個后,我們以后處理起來就非常的方便了,speech具有以下特點:? 可以實現(xiàn)連續(xù)的語音識別? 可以對語 音文件或者語音流進行識別? 最佳化自由格式的聽寫(可理解為多語言支持)和搜索式的字符串官方文檔:? Snip20160618_28.pngSnip20160618_29.png核心代碼:[objc] view plain copy print?在CODE上查看代碼片派生到我的代碼片
#import//1.創(chuàng)建本地化標識符? ? ? NSLocale *local =[[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];? ? ? //
2.創(chuàng)建一個語音識別對象? ? ? 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.發(fā)送一個請求? ??
? [sf recognitionTaskWithRequest:res resultHandler:^(SFSpeechRecognitionResult * _Nullable result, NSError * _Nullable error) {? ? ? ? ?
?if (error!=nil) {? ? ? ? ? ?
?? NSLog(@"語音識別解析失敗,%@",error);? ? ? ? ? }? ? ? ?
?? else? ? ? ? ? {? ? ? ? ? ??
? //解析正確? ? ? ? ? ? ? NSLog(@"---%@",result.bestTranscription.formattedString);? ? ??
? ? }? ? ? }];? /**? ? ?
語音識別同樣的需要真機進行測試 ,因為需要硬件的支持,還需要訪問權(quán)限? ? ***/
2.UITabBarController 中的改進? ? ? 在iOS 10之前,tabBarItem上的文字顏色,默認是 藍色,上面的新消息提醒數(shù)字badge 默認是紅色的,未選中的TabBarItem的文字顏色默認是黑色的,我們修改的話,也只能修改它的默認顏色 ,其它的就不能進行個性化定制,使用起來非常的不方便,iOS10之后我們可以輕松個性化定制了。? ? 核心代碼:[objc] view plain copy print?在CODE上查看代碼片派生到我的代碼片//
1.創(chuàng)建出三個UIViewcontroller 對象? ? ? ? ? ? OneViewController *oneVc =[[OneViewController alloc] init];? ? ? ? ? ? //
2.設(shè)置每一個控制器上的tabbar? ? ? oneVc.view.backgroundColor =[UIColor redColor];? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //設(shè)置標題? ? ? oneVc.tabBarItem.title = @"首頁";? ? ? ? ? ? ? ? ? ??
TwoViewController *twovC =[[TwoViewController alloc] init];? ? ? ? ? ?
?twovC.view.backgroundColor =[UIColor purpleColor];? ? ? ? ? ? ? ? ? ?
?//設(shè)置標題? ? ? twovC.tabBarItem.title = @"圈子";? ??
?ThreeViewController *threVC =[[ThreeViewController alloc] init];? ? ?
?threVC.view.backgroundColor =[UIColor blueColor];? ? ? ? ? ? ? //
設(shè)置標題? ? ? threVC.tabBarItem.title = @"社交";? ? ? ? ? ? ? ? ? ? //
2.將創(chuàng)建好的三個普通控制器加入到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 中屬性? ? ? ? ? ? //
數(shù)字提醒的顏色? 在iOS 10之前的版本默認都是數(shù)字提醒都是紅色? ? ??
oneVc.tabBarItem.badgeColor =[UIColor orangeColor];? ? ? oneVc.tabBarItem.badgeValue =@"90";? ? ? ? ? ? //
將tabBarItem 中數(shù)字提醒默認的白色改掉? 使用富文本修改? ? ??
[oneVc.tabBarItem setBadgeTextAttributes:@{? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NSForegroundColorAttributeName:[UIColor blackColor]? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } forState:UIControlStateNormal];??
3.iOS10.0中字體跟隨系統(tǒng)設(shè)置變化大小? ? ? 在以前如果說我們想改變APP中程序的字體大小,我們只能自定義字體或者使用runtime進行處理,或者都得設(shè)置UIFont,非常的不妨百年,從iOS 10蘋果官方允許我們自定義設(shè)置? 核心代碼:[objc] view plain copy print?在CODE上查看代碼片派生到我的代碼片/*? ? ? 在iOS 10當中,當咱們用戶將手機的字體大小進行了設(shè)置調(diào)整之后,那么app中設(shè)置相關(guān)代碼字體也會跟著一起變化 ,支持常見一些字體UI控件 比如uilabel uibutton? ? ? **/? ? ? [super viewDidLoad];? ? ? ? ? ? //設(shè)置字體的改變大小? ? ? self.labels.font =[UIFont preferredFontForTextStyle:UIFontTextStyleBody];? ? ? //允許改變? ? ? ? ? ? /*? ? ? ? 蘋果官方明確的告訴你必須和? preferredFontForTextStyle 或者preferredFontForTextStyle:(NSString *)style compatibleWithTraitCollection 進行結(jié)合使用? ? ? ? 注意這里不支持模擬器操作? ? ? **/? ? ? ? ? ?
?self.labels.adjustsFontForContentSizeCategory = YES;??
4. UIViewPropertyAnimator屬性動畫器? 那么在iOS 10之前,我們使用UIView 做動畫效果或者自定義一些layer 的動畫,如果開始了,一般無法進行停止操作更不能暫停操作,而且一些非常復(fù)雜的動畫處理也比較麻煩,但是在iOS10,蘋果退出了一個全新的API? UIViewPropertyAnimator,可供我們處理動畫操作UIViewPropertyAnimator 是 iOS 10 中新增的一個執(zhí)行 View 動畫的類,具有以下特點:? 可中斷性? 可擦除? 可反轉(zhuǎn)性? 豐富的動畫時間控制功能官方文檔:? Snip20160618_30.pngSnip20160618_31.png核心代碼:[objc] view plain copy print?在CODE上查看代碼片派生到我的代碼片#import "ViewController.h"? @interface ViewController ()? @property(nonatomic,strong)UIView *myView;? @property(nonatomic,strong)UIViewPropertyAnimator *myViewPro;? @end? @implementation ViewController? - (void)viewDidLoad {? ? ? [super viewDidLoad];? ? ? ? ? ? //
1.創(chuàng)建一個View對象? ? ? UIView *Views =[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];? ? ? Views.backgroundColor =[UIColor yellowColor];? ? ? [self.view addSubview:Views];? ? ? //
2.創(chuàng)建一個外部的變量進行引用? ? ? ? ? ? self.myView = Views;? ? ? ? ? ? ? ? ? ? //
3.創(chuàng)建一個view 動畫器? ? ? UIViewPropertyAnimator *viewPro? =[UIViewPropertyAnimator runningPropertyAnimatorWithDuration:1.0 delay:30.0 options:UIViewAnimationOptionCurveLinear animations:^{? ? ? ? ? //使用View動畫器修改View的frame? ? ? ? ? self.myView.frame = CGRectMake(230, 230, 130, 130);? ? ? } completion:nil];? ? ? ? ? ? self.myViewPro = viewPro;? }? //結(jié)束? - (IBAction)stop:(id)sender {? ? ? ? ? ? // YES 和NO 適用于設(shè)置當前這個屬性動畫器是否可以繼續(xù)使用? ? ? [self.myViewPro stopAnimation:YES];? }? //
繼續(xù)? - (IBAction)continued:(id)sender {? ? ? ? ? ? ? ? ? ? //UITimingCurveProvider? ? ? /**? ? @property(nullable, nonatomic, readonly) UICubicTimingParameters *cubicTimingParameters;? ? @property(nullable, nonatomic, readonly) UISpringTimingParameters *springTimingParameters;? ? ? ? ? ? **/? ? ? //設(shè)置彈簧效果 DampingRatio取值范圍是 0-1? ? ? ? ? ? //這個取值 決定彈簧抖動效果 的大小 ,越往? 0 靠近那么就越明顯? ? ? UISpringTimingParameters *sp =[[UISpringTimingParameters alloc] initWithDampingRatio:0.01];? ? ? ? ? ? //設(shè)置一個動畫的效果? //? ? UICubicTimingParameters *cub =[[UICubicTimingParameters alloc] initWithAnimationCurve:UIViewAnimationCurveEaseInOut];? ? ? ? ? ? ? //durationFactor? 給一個默認值 1就可以? ? ? [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中設(shè)置顏色只能通過RGB 來表示,在iOS原生還不支持#16進制寫法,還得自己寫分類去處理,我們知道RGB表示的顏色是優(yōu)先的,而且也是不精準的,那么在iOS10中,蘋果官方新增了colorWithDisplayP3Red方法核心代碼:[objc] view plain copy print?在CODE上查看代碼片派生到我的代碼片+ (? UIColor? *)colorWithDisplayP3Red:(? CGFloat? )displayP3Red green:(? CGFloat? )green blue:(? CGFloat? )blue alpha:(? CGFloat? )alpha? NS_AVAILABLE_IOS? (? 10? _0);? 6.UIApplication對象中openUrl被廢棄? 在iOS 10.0以前的年代,我們要想使用應(yīng)用程序去打開一個網(wǎng)頁或者進行跳轉(zhuǎn),直接使用[[UIApplication sharedApplication] openURL 方法就可以了,但是在iOS 10 已經(jīng)被廢棄了,因為使用這種方式,處理的結(jié)果我們不能攔截到也不能獲取到,對于開發(fā)是非常不利的,在iOS 10全新的退出了? [[UIApplication sharedApplication] openURL:nil options:nil completionHandler:nil];有一個成功的回調(diào)block 可以進行監(jiān)視。? 蘋果官方解釋:[objc] view plain copy print?在CODE上查看代碼片派生到我的代碼片//說明在iOS 10.0中openUrl方法已經(jīng)廢棄了 改為openURL:nil options:nil completionHandler:^(BOOL success? ? ? /*? ? ? // Options are specified in the section below for openURL options. An empty options dictionary will result in the same? ? ? // behavior as the older openURL call, aside from the fact that this is asynchronous and calls the completion handler rather? ? ? // than returning a result.? ? ? // The completion handler is called on the main queue.? 關(guān)鍵代碼:[objc] view plain copy print?在CODE上查看代碼片派生到我的代碼片[[UIApplication sharedApplication] openURL:nil options:nil completionHandler:^(BOOL success) {? ? ? ? ? ? ? ? }];? 當然除了以上的這些,其它的還有很多,比如下面這些6. SiriKit 在 iOS 10 里面開發(fā)者可以使用 Siri SDK,毫無疑問這也是 iOS 10 最重要的 SDK。從此開發(fā)者可以使用原生API提供語音搜索、語音轉(zhuǎn)文字消息甚至更多常見語音功能。7.? User Notifications 這個 API 讓你可以處理本地或遠程的用戶通知,并且可以基于某個條件,例如時間或者地理位置。這個異常強大,貌似可以攔截并替換自己 app 發(fā)下來的 payload,并且在之前版本SDK的本地通知框架已經(jīng)被廢棄了,在上一篇帖子有所講到以及代碼都有展示。8.CallKit? 繼2014年蘋果推出VoIP證書后,這次VoIP 接口的開放,以及一個全新的 App Extension,簡直是VOIP的福音,可見蘋果對VOIP的重視。callkit框架 VoIP應(yīng)用程序集成與iPhone的用戶界面,給用戶一個很棒的經(jīng)歷。用這個框架來讓用戶查看和接聽電話的鎖屏和VoIP管理聯(lián)系人電話在手機APP的收藏夾和歷史的觀點。callkit還介紹了應(yīng)用程序的擴展,使呼叫阻塞和來電識別。您可以創(chuàng)建一個應(yīng)用程序擴展,可以將一個電話號碼與一個名稱聯(lián)系起來,或者告訴系統(tǒng)當一個號碼應(yīng)該被阻止。9.第三方鍵盤的改進? ? 非常非常重要,第三方鍵盤一直都不能很方便的擁有長按地球鍵的功能,現(xiàn)在有了。通過 handleInputModeListFromView:withEvent: 可以彈出系統(tǒng)鍵盤列表。同時使用 documentInputMode 可以檢測輸入上下文中的語言,你可以對輸入方式進行一些類似于對齊方式的調(diào)整。10.iOS10 對隱私權(quán)限的管理? ? ? 比如訪問的攝像頭、麥克風(fēng)等硬件,都需要提前請求應(yīng)用權(quán)限、允許后才可以使用,或者現(xiàn)在要提前聲明,雖然以往要求不嚴格。在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 NSCameraUsageDescription key with a string value explaining to the user how the app uses this data. 你需要在info.plist文件 添加一個“NSContactsUsageDescription ”的Key,Value添加一個描述。ssss.png視頻播放 需要在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.? 訪問用戶的隱私數(shù)據(jù),并且沒有向用戶說明,必須在plist(info.plist)中配置這個key? NSAppleMusicUsageDescription 并且向用戶說明.11.Xcode7 和Xcode 8項目中的xib兼容問題? 在Xcode8上打開項目要小心,尤其是對于xib過程,在變動后可不要隨意點保存,否則當你回頭用Xcode7打開時時發(fā)現(xiàn)報錯了,Xcode保存的xib在xcode7上是識別不了的!12.APPlePlay(蘋果支付)? ? ? ? ? 可用于 SFSafariViewController? 可用于沒有UI的extensions中? 在 iMessage 應(yīng)用中也支持 ApplePay13.CoreData提升了并發(fā)訪問性能14.刷新控件(UIRefresh Control)iOS系統(tǒng)自帶的刷新控件支持所有的 UIScrollView 以及其子類,比如說 UICollectionView,UITableView。核心代碼:[objc] view plain copy print?在CODE上查看代碼片派生到我的代碼片//? //? UIRefreshControlHosting.h? //? UIKit? //? //? Copyright 2016 Apple Inc. All rights reserved.? //? #import@class UIRefreshControl;? NS_CLASS_AVAILABLE_IOS(10_0) @protocol UIRefreshControlHosting@property (nonatomic, strong, nullable) UIRefreshControl *refreshControl __TVOS_PROHIBITED;
@end
15.GCD多線程支持創(chuàng)建私有隊列