-(void)drawRect:(CGRect)rect
{
[[UIColor clearColor]setFill];
UIRectFill(rect);
NSInteger pulsingCount = ;
double animationDuration = ; CALayer * animationLayer = [[CALayer alloc]init];
self.animationLayer = animationLayer; for (int i = ; i < pulsingCount; i++) {
CALayer * pulsingLayer = [[CALayer alloc]init];
pulsingLayer.frame = CGRectMake(, , rect.size.width, rect.size.height);
pulsingLayer.backgroundColor = [UIColor colorWithRed:92.0/255.0 green:181.0/255.0 blue:217.0/255.0 alpha:1.0].CGColor;
pulsingLayer.borderColor = [UIColor colorWithRed:92.0/255.0 green:181.0/255.0 blue:217.0/255.0 alpha:1.0].CGColor;
pulsingLayer.borderWidth = 1.0;
pulsingLayer.cornerRadius = rect.size.height/; CAMediaTimingFunction * defaultCurve = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; CAAnimationGroup * animationGroup = [[CAAnimationGroup alloc]init];
animationGroup.fillMode = kCAFillModeBoth;
animationGroup.beginTime = CACurrentMediaTime() + (double)i * animationDuration/(double)pulsingCount;
animationGroup.duration = animationDuration; animationGroup.repeatCount = HUGE_VAL;
animationGroup.timingFunction = defaultCurve; CABasicAnimation * scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.autoreverses = NO;
scaleAnimation.fromValue = [NSNumber numberWithDouble:0.2];
scaleAnimation.toValue = [NSNumber numberWithDouble:1.0]; CAKeyframeAnimation * opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.values = @[[NSNumber numberWithDouble:1.0],[NSNumber numberWithDouble:0.5],[NSNumber numberWithDouble:0.3],[NSNumber numberWithDouble:0.0]];
opacityAnimation.keyTimes = @[[NSNumber numberWithDouble:0.0],[NSNumber numberWithDouble:0.25],[NSNumber numberWithDouble:0.5],[NSNumber numberWithDouble:1.0]];
animationGroup.animations = @[scaleAnimation,opacityAnimation]; [pulsingLayer addAnimation:animationGroup forKey:@"pulsing"];
[animationLayer addSublayer:pulsingLayer];
}
self.animationLayer.zPosition = -;//重新加载时,使动画至底层
[self.layer addSublayer:self.animationLayer]; CALayer * thumbnailLayer = [[CALayer alloc]init];
thumbnailLayer.backgroundColor = [UIColor whiteColor].CGColor;
CGRect thumbnailRect = CGRectMake(, , , );
thumbnailRect.origin.x = (rect.size.width - thumbnailRect.size.width)/2.0;
thumbnailRect.origin.y = (rect.size.height - thumbnailRect.size.height)/2.0;
thumbnailLayer.frame = thumbnailRect;
thumbnailLayer.cornerRadius = 23.0;
thumbnailLayer.borderWidth = 1.0;
thumbnailLayer.masksToBounds = YES;
thumbnailLayer.borderColor = [UIColor whiteColor].CGColor;
UIImage * thumbnail = self.thumbnailImage;
thumbnailLayer.contents = (id)thumbnail.CGImage;
thumbnailLayer.zPosition = -;
[self.layer addSublayer:thumbnailLayer];
}

iOS 实现类似雷达效果的核心代码的更多相关文章

  1. Ios 实现 滑动cell 伸缩的核心代码

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat viewHeight = scrollView.height + sc ...

  2. 利用Render Texture实现游戏的小雷达效果(摄影机分屏)

    最近游戏蛮牛在举办一个活动,就是要做出这样的效果: 题目:实现游戏分屏效果 要求:1.        分屏,且分割线不规则(即非水平或垂直):2.        各屏可单独操作(移动.缩放),操作指该 ...

  3. iOS开发——实用技术OC篇&8行代码教你搞定导航控制器全屏滑动返回效果

    8行代码教你搞定导航控制器全屏滑动返回效果 前言 如果自定了导航控制器的自控制器的leftBarButtonItem,可能会引发边缘滑动pop效果的失灵,是由于 self.interactivePop ...

  4. ios 类似的效果淘宝商品详细页面

    今天试着写ios 分类似影响淘宝的商品详细页面 我使用第三方库EGORefreshTableHeaderView有一个下拉效果刷新PWLoadMoreTableFooterView上拉电阻负载许多其他 ...

  5. AJ学IOS(40)UI之核心动画_抖动效果_CAKeyframeAnimation

    AJ分享,必须精品 效果: 效果一: 效果二: 代码: // // NYViewController.m // 图片抖动 // // Created by apple on 15-5-8. // Co ...

  6. iOS 高效添加圆角效果实战讲解

    圆角(RounderCorner)是一种很常见的视图效果,相比于直角,它更加柔和优美,易于接受.但很多人并不清楚如何设置圆角的正确方式和原理.设置圆角会带来一定的性能损耗,如何提高性能是另一个需要重点 ...

  7. iOS开发-添加圆角效果高效实现

    圆角(RounderCorner)是一种很常见的视图效果,相比于直角,它更加柔和优美,易于接受.但很多人并不清楚如何设置圆角的正确方式和原理.设置圆角会带来一定的性能损耗,如何提高性能是另一个需要重点 ...

  8. jQuery雷达扫描切换幻灯片代码

    基于jQuery雷达扫描切换幻灯片代码.这是一款切换效果类似雷达扫描,支持鼠标滚轮滚动切换.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div class=" ...

  9. ios图片轮播效果

    代码地址如下:http://www.demodashi.com/demo/11959.html ImageCarousel 简单封装的图片轮播器 内存过大由于我加载的图片分辨率较高(4k) 文件目录 ...

随机推荐

  1. perl学习之路1

    一切要从Hollo world开始 公司要用perl....啊, 不会只能自学了, 毕竟是公司啊, 不是学校...公司不学习就滚蛋了...惨惨惨 因为是学习嘛, 感觉开虚拟机比较麻烦所以直接用了个 瘟 ...

  2. OA(权限管理初步模块)

    权限管理:一般指根据系统设置的安全规则或者安全策略,用户可以访问而且只能访问自己被授权的资源,不多不少.权限管理几乎出现在任何系统里面,只要有用户和密码的系统. 根据权限管理的套路,我们一般从这三个角 ...

  3. nginx-nginx.conf脚本

    user www www; worker_processes ; error_log /usr/local/nginx/logs/error.log info ; pid /var/run/nginx ...

  4. 完善ecshop的mysql类

    前篇文章中,我提及到了如何<提取ecshop的mysql类>.但是没有数据库前缀的写法 废话不说,上步骤(目录结构请参考提取ecshop的mysql类) 修改connfig.php为 &l ...

  5. 关于Java8函数式编程你需要了解的几点

    函数式编程与面向对象的设计方法在思路和手段上都各有千秋,在这里,我将简要介绍一下函数式编程与面向对象相比的一些特点和差异. 函数作为一等公民 在理解函数作为一等公民这句话时,让我们先来看一下一种非常常 ...

  6. IOS 真机调试

    真机调试的步骤: 1.注册成为苹果开发者(99$) 2.登陆苹果开发者主页 https://developer.apple.com/membercenter/index.action 3.点击 Cer ...

  7. PostgreSQL 9.3发布

    9月9日,PostgreSQL全球开发组宣布了9.3版发布的消息.从2010年9.0版开始,PostgreSQL已经连续四个版本稳定地按时在每年9月中旬发布,从一个侧面也显示了开发团队的强大实力. 9 ...

  8. Android应用安全开发之浅谈网页打开APP

    一.网页打开APP简介 Android有一个特性,可以通过点击网页内的某个链接打开APP,或者在其他APP中通过点击某个链接打开另外一个APP(AppLink),一些用户量比较大的APP,已经通过发布 ...

  9. ABP框架理论学习之Debugging

    返回总目录 所有的官方ABP nuget包都是支持GitLink的,这意味着你可以在项目中轻松地调试所有的以Abp为前缀的Nuget包. 要开启这项支持,"启用源服务器支持"选项应 ...

  10. 领域驱动设计系列 (六):CQRS

    CQRS是Command Query Responsibility Seperation(命令查询职责分离)的缩写. 世上很多事情都比较复杂,但是我们只要进行一些简单的分类后,那么事情就简单了很多,比 ...