概述

根据UIBezierPath和CAShapeLayer自定义倒计时进度条,适用于app启动的时候设置一个倒计时关闭启动页面。可以设置进度条颜色,填充颜色,进度条宽度以及点击事件等。

详细

代码下载:http://www.demodashi.com/demo/10700.html

我们都知道 APP启动时加载的是LaunchImage 这张静态图。现在好多应用启动时都是动态的,并且右上角可选择跳过。

这里介绍一下自己在做这种动画时的一种方案。

启动图依然是加载的,只不过是一闪而过,这时候我想到的是拿到当前的LaunchImage图片,然后进行处理,造成一种改变了LaunchImage动画的假象。

思路如下:

根据UIBezierPath和CAShapeLayer自定义倒计时进度条,适用于app启动的时候设置一个倒计时关闭启动页面。可以设置进度条颜色,填充颜色,进度条宽度以及点击事件等。

一、设置跳过按钮

ZLDrawCircleProgressBtn.h:

/***  set complete callback**  @param lineWidth line width*  @param block     block*  @param duration  time*/
- (void)startAnimationDuration:(CGFloat)duration withBlock:(DrawCircleProgressBlock )block;

ZLDrawCircleProgressBtn.m :

先初始化相关跳过按钮及进度圈:

// 底部进度条圈
@property (nonatomic, strong) CAShapeLayer *trackLayer;
// 表层进度条圈
@property (nonatomic, strong) CAShapeLayer *progressLayer;
@property (nonatomic, strong) UIBezierPath *bezierPath;
@property (nonatomic, copy)   DrawCircleProgressBlock myBlock;
- (instancetype)initWithFrame:(CGRect)frame
{if (self == [super initWithFrame:frame]) {self.backgroundColor = [UIColor clearColor];[self.layer addSublayer:self.trackLayer];}return self;
}
- (UIBezierPath *)bezierPath {if (!_bezierPath) {CGFloat width = CGRectGetWidth(self.frame)/2.0f;CGFloat height = CGRectGetHeight(self.frame)/2.0f;CGPoint centerPoint = CGPointMake(width, height);float radius = CGRectGetWidth(self.frame)/2;_bezierPath = [UIBezierPath bezierPathWithArcCenter:centerPointradius:radiusstartAngle:degreesToRadians(-90)endAngle:degreesToRadians(270)clockwise:YES];}return _bezierPath;
}

底部进度条圈:

- (CAShapeLayer *)trackLayer {if (!_trackLayer) {_trackLayer = [CAShapeLayer layer];_trackLayer.frame = self.bounds;// 圈内填充色_trackLayer.fillColor = self.fillColor.CGColor ? self.fillColor.CGColor : [UIColor clearColor].CGColor ;_trackLayer.lineWidth = self.lineWidth ? self.lineWidth : 2.f;// 底部圈色_trackLayer.strokeColor = self.trackColor.CGColor ? self.trackColor.CGColor : [UIColor colorWithRed:197/255.0 green:159/255.0 blue:82/255.0 alpha:0.3].CGColor ;_trackLayer.strokeStart = 0.f;_trackLayer.strokeEnd = 1.f;_trackLayer.path = self.bezierPath.CGPath;}return _trackLayer;
}

表层进度条圈:

- (CAShapeLayer *)progressLayer {if (!_progressLayer) {_progressLayer = [CAShapeLayer layer];_progressLayer.frame = self.bounds;_progressLayer.fillColor = [UIColor clearColor].CGColor;_progressLayer.lineWidth = self.lineWidth ? self.lineWidth : 2.f;_progressLayer.lineCap = kCALineCapRound;// 进度条圈进度色_progressLayer.strokeColor = self.progressColor.CGColor ? self.progressColor.CGColor  : [UIColor  colorWithRed:197/255.0 green:159/255.0 blue:82/255.0 alpha:1].CGColor;_progressLayer.strokeStart = 0.f;CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];pathAnimation.duration = self.animationDuration;pathAnimation.fromValue = @(0.0);pathAnimation.toValue = @(1.0);pathAnimation.removedOnCompletion = YES;pathAnimation.delegate = self;[_progressLayer addAnimation:pathAnimation forKey:nil];_progressLayer.path = _bezierPath.CGPath;}return _progressLayer;
}

设置代理回调:

#pragma mark -- CAAnimationDelegate
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {if (flag) {self.myBlock();}
}
#pragma mark ---
- (void)startAnimationDuration:(CGFloat)duration withBlock:(DrawCircleProgressBlock )block {self.myBlock = block;self.animationDuration = duration;[self.layer addSublayer:self.progressLayer];
}

二、启动页

ZLStartPageView.h :

露出 显示引导页面方法:

/***  显示引导页面方法*/
- (void)show;

ZLStartPageView.m :

  1. 初始化启动页

// 启动页图
@property (nonatomic,strong) UIImageView *imageView;
// 跳过按钮
@property (nonatomic, strong) ZLDrawCircleProgressBtn *drawCircleBtn;
- (instancetype)initWithFrame:(CGRect)frame {if (self = [super initWithFrame:frame]) {// 1.启动页图片_imageView = [[UIImageView alloc]initWithFrame:frame];_imageView.contentMode = UIViewContentModeScaleAspectFill;_imageView.image = [UIImage imageNamed:@"LaunchImage_667h"];[self addSubview:_imageView];// 2.跳过按钮ZLDrawCircleProgressBtn *drawCircleBtn = [[ZLDrawCircleProgressBtn alloc]initWithFrame:CGRectMake(kscreenWidth - 55, 30, 40, 40)];drawCircleBtn.lineWidth = 2;[drawCircleBtn setTitle:@"跳过" forState:UIControlStateNormal];[drawCircleBtn setTitleColor:[UIColor  colorWithRed:197/255.0 green:159/255.0 blue:82/255.0 alpha:1] forState:UIControlStateNormal];drawCircleBtn.titleLabel.font = [UIFont systemFontOfSize:14];[drawCircleBtn addTarget:self action:@selector(removeProgress) forControlEvents:UIControlEventTouchUpInside];[self addSubview:drawCircleBtn];self.drawCircleBtn = drawCircleBtn;}return self;
}

2. 显示启动页且完成时候回调移除

- (void)show {//  progress 完成时候的回调__weak __typeof(self) weakSelf = self;[weakSelf.drawCircleBtn startAnimationDuration:showtime withBlock:^{[weakSelf removeProgress];}];UIWindow *window = [UIApplication sharedApplication].keyWindow;[window addSubview:self];
}

3. 移除启动页面

- (void)removeProgress {self.imageView.transform = CGAffineTransformMakeScale(1, 1);self.imageView.alpha = 1;[UIView animateWithDuration:0.3 animations:^{self.drawCircleBtn.hidden = NO;self.imageView.alpha = 0.05;self.imageView.transform = CGAffineTransformMakeScale(5, 5);} completion:^(BOOL finished) {self.drawCircleBtn.hidden = YES;[self.imageView removeFromSuperview];}];
}

三、动态启动页的显示代码放在AppDeleate中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[HomeViewController alloc] init]];[self.window makeKeyAndVisible];[self setupStartPageView];return YES;
}

设置启动页:

- (void)setupStartPageView {ZLStartPageView *startPageView = [[ZLStartPageView alloc] initWithFrame:self.window.bounds];[startPageView show];
}

这个时候就可以可以测试喽~

四、压缩文件截图

界面性问题可以根据自己项目需求调整即可, 具体可参考代码, 项目能够直接运行!

注:本文著作权归作者,由demo大师(http://www.demodashi.com)宣传,拒绝转载,转载需要作者授权

iOS-启动动态页跳过设计思路相关推荐

  1. iOS-启动动态页跳过设计思路 立即下载

    代码下载地址: http://www.demodashi.com/demo/10700.html 我们都知道 APP启动时加载的是LaunchImage 这张静态图.现在好多应用启动时都是动态的,并且 ...

  2. 各种风格简洁单页响应式html5模板_简洁 响应式 单页 跳转 设计 案例 源码340多套订餐企业模板高大尚响应式网站模板html5网页静态模板Bootstrap扁平化网站源码css3手机seo自适响

    各种风格简洁单页响应式html5模板_简洁 响应式 单页 跳转 设计 案例 源码340多套订餐企业模板高大尚响应式网站模板html5网页静态模板Bootstrap扁平化网站源码css3手机seo自适响 ...

  3. iOS 组件化,插件化,模块化设计思路分析

    iOS 组件化,插件化设计思路分析 前言 随着用户的需求越来越多,对App的用户体验也变的要求越来越高.为了更好的应对各种需求,开发人员从软件工程的角度,将App架构由原来简单的MVC变成MVVM,V ...

  4. 驴妈妈客户端频道页模块化设计思路

    Hello ,iOSTips的读者朋友们大家好,我是来自驴妈妈的[傅说君],喜欢一本正经的傅说八道.由于老峰已经放假出去浪了,今天的文章由我来分享,Trust me,傅说君分享的都是干货,嗯比老峰的干 ...

  5. iOS 组件化 —— 路由设计思路分析

    原文 前言 随着用户的需求越来越多,对App的用户体验也变的要求越来越高.为了更好的应对各种需求,开发人员从软件工程的角度,将App架构由原来简单的MVC变成MVVM,VIPER等复杂架构.更换适合业 ...

  6. iOS路由设计(四)路由设计思路分析

    http://www.jianshu.com/p/76da56b3bd55 前言 随着用户的需求越来越多,对App的用户体验也变的要求越来越高.为了更好的应对各种需求,开发人员从软件工程的角度,将Ap ...

  7. Flutter——踩坑之旅(iOS闪屏页+启动页 闪屏之后会黑一下才进入启动页)

    程序猿日常 flutter填坑--iOS闪屏页+启动页效果优化 闪屏之后会黑一下进入启动页 问题描述 大部分app都有自己的启动页,我们经常在启动页做一些判断逻辑,例如 是否第一次启动app,第一次启 ...

  8. 实现动态表单功能设计思路

    实现动态表单功能设计思路 文章目录 **实现动态表单功能设计思路** 一.业务场景 二.设计思路 三.数据库设计 四.页面展示 操作流程 部分代码 一.业务场景 业务只涉及简单的增删改查,但是业务类型 ...

  9. 案例分享,Appium+Python实现APP启动页跳转到首页!

    下面以 MSN news 为例,实现启动APP后跳转到首页的功能,包含使用list进行元素定位.try except else 进行是否首次启动APP判断,logging 进行日志记录等功能. Pyt ...

最新文章

  1. DeepLabv3:语义图像分割
  2. varnish 防盗链
  3. html内联框上下重叠,如何解决IOS端两个内联块元素无法上下对齐的问题?
  4. UICollectionView 应用
  5. TextView跑马灯效果
  6. DataReader终结篇
  7. OpenCV图像处理(1)——指定文件夹写入图像
  8. PostgreSQL逻辑优化——查询优化分析
  9. ffplay播放flv文件没有声音的解决方法
  10. 【机器人学:运动规划】快速搜索随机树(RRT---Rapidly-exploring Random Trees)入门及在Matlab中演示
  11. angular项目如何配置国际化(i18n)?
  12. 哪种手机便签软件可以打印,支持打印的手机便签软件
  13. 每周全球科技十大新闻(2021.6.21-6.27)
  14. 解决VsCode有时无法输入的问题及vim插件下NORMAL模式的快捷操作
  15. STM32 | C语言对寄存器的封装
  16. 互联网日报 | 携程实现疫情以来首季度盈利;360安全浏览器辟谣收费传闻;滴滴再推123全民拼车日...
  17. 项目8 数据库的安全性维护
  18. 适合Python入门的5本基础书籍
  19. 非居民账户(NRA)和OSA
  20. 【论文阅读】研究生论文学习技巧

热门文章

  1. C++ 单例模式中处理在类中声明一个指向一个自己的指针,在编译时显示定义的指针未定义的处理办法
  2. 两个苹果手机怎么传通讯录_苹果手机怎么导入通讯录?教你换机快速导入
  3. 【C语言】成绩统计(结构)
  4. tcp_v4_connect函数分析
  5. “手把手教你学linux驱动开发”OK6410系列之02---虚拟字符设备
  6. 读写自旋锁详解,第 2 部分(来自IBM)
  7. Java学习日报—SQL基础—2021/11/29
  8. QT5开发及实例学习之十二Qt5图像坐标变换
  9. 《RabbitMQ 实战指南》第四章 RabbitMQ进阶(上)
  10. WordPress文章阅读量统计和显示(非插件, 刷新页面不累加)