日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iOS10的新特征

發布時間:2024/5/21 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iOS10的新特征 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • iOS10中字體跟隨系統設置變化大小
/**在iOS10中,當用戶將手機的字體大小進行了設置調整之后,那么app中設置相關代碼字體也會跟著一起變化,支持常見一*些字體UI控件 比如UILabel、UIButton等**/[super viewDidLoad];//設置字體的改變大小self.labels.font =[UIFont preferredFontForTextStyle:UIFontTextStyleBody];//允許改變/*蘋果官方明確須和 preferredFontForTextStyle或者preferredFontForTextStyle:(NSString *)style compatibleWithTraitCollection 進行結合使用。注意:這里不支持模擬器操作**/self.labels.adjustsFontForContentSizeCategory = YES;
  • UIApplication對象的openUrl被廢棄:iOS10之前直接使用[[UIApplication sharedApplication] openURL 方法就可以使用應用程序去打開一個網頁或者進行跳轉,但是在iOS 10之后,有一個成功的回調block 可以進行監視,進而去處理返回的結果;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@""] options:nil completionHandler:^(BOOL success) {}];
  • 語音識別:speech具有以下特點:
    可以實現連續的語音識別
    可以對語 音文件或者語音流進行識別
    最佳化自由格式的聽寫(可理解為多語言支持)和搜索式的字符串
    核心代碼:(需要引入“ Speech/Speech.h”庫)
//1.創建本地化標識符NSLocale *locale =[[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//2.創建一個語音識別對象SFSpeechRecognizer *recognizer =[[SFSpeechRecognizer alloc] initWithLocale:locale];//3.將bundle 中的資源文件加載出來返回一個urlNSURL *url =[[NSBundle mainBundle] URLForResource:@"xxx.mp3" withExtension:nil];//4.將資源包中獲取的url傳遞給request對象SFSpeechURLRecognitionRequest *res =[[SFSpeechURLRecognitionRequest alloc] initWithURL:url];//5.發送一個請求[recognizer recognitionTaskWithRequest:res resultHandler:^(SFSpeechRecognitionResult * _Nullable result, NSError * _Nullable error) {if (error != nil) {NSLog(@"語音識別解析失敗,%@",error);} else {//解析正確NSLog(@"%@",result.bestTranscription.formattedString);}}];
  • UIViewPropertyAnimator屬性動畫器:在iOS10,蘋果推出了一個全新的API UIViewPropertyAnimator,可供我們處理動畫操作;
    UIViewPropertyAnimator 是 iOS 10 中新增的一個執行 View 動畫的類,具有以下特點:
    1、可中斷性;
    2、可擦除;
    3、可反轉性;
    4、豐富的動畫時間控制功能。
    核心代碼:
@interface ViewController ()@property(nonatomic,strong) UIView *myView; @property(nonatomic,strong) UIViewPropertyAnimator *myViewProperty;@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的frameself.myView.frame = CGRectMake(230, 230, 130, 130);} completion:nil];self.myViewProperty = viewPro; }//結束 - (IBAction)stop:(id)sender {// YES 和NO 適用于設置當前這個屬性動畫器是否可以繼續使用[self.myViewProperty 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.0就可以[self.myViewProperty continueAnimationWithTimingParameters:sp durationFactor:1.0]; }//暫停 - (IBAction)puase:(id)sender {[self.myViewProperty pauseAnimation]; }//開始- (IBAction)start:(id)sender {[self.myViewProperty startAnimation]; }- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];}
  • UIColor 新增方法:在iOS10中,蘋果官方新增了colorWithDisplayP3Red方法
+ ( UIColor *)colorWithDisplayP3Red:( CGFloat )displayP3Red green:( CGFloat )green blue:( CGFloat )blue alpha:( CGFloat )alpha NS_AVAILABLE_IOS ( 10 _0);
  • 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 NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
    則需要在info.plist文件 添加一個“NSContactsUsageDescription ”的Key,Value添加一個描述。

  • Xcode7 和Xcode 8項目中的xib兼容問題
    在Xcode8上打開項目要小心,尤其是對于xib過程,在變動后可不要隨意點保存,否則當你回頭用Xcode7打開時時發現報錯了,Xcode8保存的xib在xcode7上是識別不了的!

  • CoreData提升了并發訪問性能

  • APPlePlay(蘋果支付):可用于 SFSafariViewController,沒有UI的extensions,在 iMessage 應用中也支持 ApplePay;

  • 刷新控件(UIRefresh Control):系統自帶的刷新控件支持所有的 UIScrollView 以及其子類,比如說 UICollectionView,UITableView。

  • GCD多線程支持創建私有隊列

  • User Notifications和CallKit以及第三方鍵盤的改進等。

總結

以上是生活随笔為你收集整理的iOS10的新特征的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。