優化了許多API,簡化了接口,去掉了沒必要要的單詞等,好比下面這幾個例子:spring
aswift
//before override func numberOfSectionsInTableView(tableView: UITableView) -> Int //now override func numberOfSections(in tableView: UITableView) -> Int
b xcode
//before NSTimer.scheduledTimerWithTimeInterval(0.35, target: self, selector: #selector(reset), userInfo: nil, repeats: true) //now Timer.scheduledTimer(timeInterval: 0.35, target: self, selector: #selector(reset), userInfo: nil, repeats: true)
c多線程
//before let blue = UIColor.blueColor() //now let blue = UIColor.blue
d併發
//before UIDevice.currentDevice() //now UIDevice.current
經過官方文檔咱們能夠看到SiriKit框架支持的六類服務分別是:app
iMessage App是一種全新的應用擴展,載體是iOS系統的Message應用,經過iMessage App,用戶能夠發送更加豐富的消息內容,享受更具交互性的會話體驗。咱們來看看它都有什麼新鮮玩意:框架
蘋果官方在文檔中新增了API Speech,那麼在之前咱們處理語音識別很是的繁瑣甚至不少時候可能須要藉助於第三方框架處理,那麼蘋果推出了這個後,咱們之後處理起來就很是的方便了。ide
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:@"XXX.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); } }];
另外,語音識別須要真機測試(硬件的支持),還須要訪問權限。
在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];
效果圖:
在之前若是說咱們想改變APP中程序的字體大小,咱們只能自定義字體或者使用runtime進行處理,或者都得設置UIFont,很是的不妨百年,從iOS 10蘋果官方容許咱們自定義設置。
核心代碼:
/* 在iOS 10當中,當我們用戶將手機的字體大小進行了設置調整以後,那麼app中設置相關代碼字體也會跟着一塊兒變化 ,支持常見一些字體UI控件 好比uilabel uibutton */ [super viewDidLoad]; //設置字體的改變大小 self.labels.font =[UIFont preferredFontForTextStyle:UIFontTextStyleBody]; //容許改變 /* 蘋果官方明確的告訴你必須和 preferredFontForTextStyle 或者preferredFontForTextStyle:(NSString *)style compatibleWithTraitCollection 進行結合使用 注意這裏不支持模擬器操做 **/ self.labels.adjustsFontForContentSizeCategory = YES;
那麼在iOS 10以前,咱們使用UIView 作動畫效果或者自定義一些layer 的動畫,若是開始了,通常沒法進行中止操做更不能暫停操做,並且一些很是複雜的動畫處理也比較麻煩,可是在iOS10,蘋果推出了一個全新的API UIViewPropertyAnimator,可供咱們處理動畫操做。
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]; //1.建立一個View對象 UIView *Views =[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; Views.backgroundColor =[UIColor yellowColor]; [self.view addSubview:Views]; //2.建立一個外部的變量進行引用 self.myView = Views; //3.建立一個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; } //結束 - (IBAction)stop:(id)sender { // YES 和NO 適用於設置當前這個屬性動畫器是否能夠繼續使用 [self.myViewPro stopAnimation:YES]; } //繼續 - (IBAction)continued:(id)sender { //UITimingCurveProvider /** @property(nullable, nonatomic, readonly) UICubicTimingParameters *cubicTimingParameters; @property(nullable, nonatomic, readonly) UISpringTimingParameters *springTimingParameters; **/ //設置彈簧效果 DampingRatio取值範圍是 0-1 //這個取值 決定彈簧抖動效果 的大小 ,越往 0 靠近那麼就越明顯 UISpringTimingParameters *sp =[[UISpringTimingParameters alloc] initWithDampingRatio:0.01]; //設置一個動畫的效果 // 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]; }
效果圖:
在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) { }];
繼2014年蘋果推出VoIP證書後,此次VoIP 接口的開放,以及一個全新的 App Extension,簡直是VOIP的福音,可見蘋果對VOIP的重視。callkit框架 VoIP應用程序集成與iPhone的用戶界面,給用戶一個很棒的經歷。用這個框架來讓用戶查看和接聽電話的鎖屏和VoIP管理聯繫人電話在手機APP的收藏夾和歷史的觀點。
CallKit還介紹了應用程序的擴展,使呼叫阻塞和來電識別。您能夠建立一個應用程序擴展,能夠將一個電話號碼與一個名稱聯繫起來,或者告訴系統當一個號碼應該被阻止。
很是很是重要,第三方鍵盤一直都不能很方便的擁有長按地球鍵的功能,如今有了。經過 handleInputModeListFromView:withEvent: 能夠彈出系統鍵盤列表。同時使用 documentInputMode 能夠檢測輸入上下文中的語言,你能夠對輸入方式進行一些相似於對齊方式的調整。
在Xcode8上打開項目要當心,尤爲是對於xib過程,在變更後可不要隨意點保存,不然當你回頭用Xcode7打開時時發現報錯了,Xcode保存的xib在xcode7上是識別不了的!
可用於 SFSafariViewController
可用於沒有UI的extensions中
在 iMessage 應用中也支持 ApplePay