网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

如何使用iOS仿抖音视频加载动画效果-创新互联

小编给大家分享一下如何使用iOS仿抖音视频加载动画效果,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

创新互联-专业网站定制、快速模板网站建设、高性价比本溪网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式本溪网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖本溪地区。费用合理售后完善,10多年实体公司更值得信赖。

实现原理

首先我创建一个视图

@interface ViewController ()@property (nonatomic, strong) UIView *playLoadingView;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //init player status bar self.playLoadingView = [[UIView alloc]init]; self.playLoadingView.backgroundColor = [UIColor whiteColor]; [self.playLoadingView setHidden:YES]; [self.view addSubview:self.playLoadingView]; //make constraintes [self.playLoadingView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self.view); make.width.mas_equalTo(1.0f); //宽 1 dp make.height.mas_equalTo(0.5f); //高 0.5 dp }]; [self startLoadingPlayAnimation:YES]; //调用动画代码}

这里我们可以看到 我们实际上创建的是一个 1pt宽度 0.5 pt的宽度 的视图

紧接着动画实现的代码

- (void)startLoadingPlayAnimation:(BOOL)isStart { if (isStart) { self.playLoadingView.backgroundColor = [UIColor whiteColor]; self.playLoadingView.hidden = NO; [self.playLoadingView.layer removeAllAnimations]; CAAnimationGroup *animationGroup = [[CAAnimationGroup alloc] init]; animationGroup.duration = 0.5; animationGroup.beginTime = CACurrentMediaTime() + 0.5; animationGroup.repeatCount = MAXFLOAT; animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; CABasicAnimation *scaleAnimation = [CABasicAnimation animation]; scaleAnimation.keyPath = @"transform.scale.x"; scaleAnimation.fromValue = @(1.0f); scaleAnimation.toValue = @(1.0f * ScreenWidth); CABasicAnimation *alphaAnimation = [CABasicAnimation animation]; alphaAnimation.keyPath = @"opacity"; alphaAnimation.fromValue = @(1.0f); alphaAnimation.toValue = @(0.5f); [animationGroup setAnimations:@[scaleAnimation, alphaAnimation]]; [self.playLoadingView.layer addAnimation:animationGroup forKey:nil]; } else { [self.playLoadingView.layer removeAllAnimations]; self.playLoadingView.hidden = YES; }}

完事 就这几行代码 搞定

其实核心的只有4行代码

CABasicAnimation *scaleAnimation = [CABasicAnimation animation];scaleAnimation.keyPath = @"transform.scale.x";scaleAnimation.fromValue = @(1.0f);scaleAnimation.toValue = @(1.0f * ScreenWidth);

关键在scaleAnimation.keyPath = @"transform.scale.x";这里我们要沿着x做缩放

缩放的得值从 1~屏幕宽度, 当然值多大自己可以控制.

如果@"transform.scale.y"则是沿着Y轴缩放

当然 如果写成@"transform.scale"那就X,Y 一起缩放 大家可以试试.

以上是“如何使用iOS仿抖音视频加载动画效果”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


分享题目:如何使用iOS仿抖音视频加载动画效果-创新互联
浏览路径:http://bjjierui.cn/article/coiscc.html

其他资讯