#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 中的改进
//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];3.iOS10.0中字体跟随系统设置变化大小
/*在iOS 10当中,当咱们用户将手机的字体大小进行了设置调整之后,那么app中设置相关代码字体也会跟着一起变化 ,支持常见一些字体UI控件 比如UILabel UIButton **/ [super viewDidLoad]; //设置字体的改变大小 self.labels.font =[UIFont preferredFontForTextStyle:UIFontTextStyleBody]; //允许改变 /* 苹果官方明确的告诉你必须和 preferredFontForTextStyle 或者preferredFontForTextStyle:(NSString *)style compatibleWithTraitCollection 进行结合使用 注意这里不支持模拟器操作 **/ self.labels.adjustsFontForContentSizeCategory = YES;4.UIViewPropertyAnimator属性动画器
#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];}效果图: 222.gif
+ (UIColor*)colorWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);//方法可以更加精准的设置颜色了。6.UIApplication对象中openUrl被废弃
[[UIApplication sharedApplication] openURL:nil options:nil completionHandler:^(BOOL success) { }];6.SiriKit
#import <Foundation/Foundation.h>@class UIRefreshControl;NS_CLASS_AVAILABLE_IOS(10_0)@protocol UIRefreshControlHosting <NSObject>@property (nonatomic, strong, nullable) UIRefreshControl *refreshControl __TVOS_PROHIBITED;@endXcode 8 新特性(正在整理..)
禁用该Xcode Debug Console方法:Product --> Scheme --> Edit Scheme 在打开的窗口中选择run 在 Environment Variables中添加OS_ACTIVITY_MODE对应的value为disable后close退出即可。
3.注释快捷键(command + /)失效
这个是因为为了苹果解决xcode ghost,把插件屏蔽了解决方法,命令运行:
$ sudo /usr/libexec/xpccachectl
注意:然后必须重启电脑后生效