#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);
}
}];
//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];
/*在iOS 10当中,当咱们用户将手机的字体大小进行了设置调整之后,那么app中设置相关代码字体也会跟着一起变化 ,支持常见一些字体UI控件 比如UILabel UIButton **/ [super viewDidLoad]; //设置字体的改变大小 self.labels.font =[UIFont preferredFontForTextStyle:UIFontTextStyleBody]; //允许改变 /* 苹果官方明确的告诉你必须和 preferredFontForTextStyle 或者preferredFontForTextStyle:(NSString *)style compatibleWithTraitCollection 进行结合使用 注意这里不支持模拟器操作 **/ self.labels.adjustsFontForContentSizeCategory = YES;
#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];
}
+ (UIColor*)colorWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0); //方法可以更加精准的设置颜色了。
[[UIApplication sharedApplication] openURL:nil options:nil completionHandler:^(BOOL success) {
}];
#import <Foundation/Foundation.h> @class UIRefreshControl;NS_CLASS_AVAILABLE_IOS(10_0) @protocol UIRefreshControlHosting <NSObject> @property (nonatomic, strong, nullable) UIRefreshControl *refreshControl __TVOS_PROHIBITED; @end
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有