iOS 圆的放大动画效果

第一步:创建一个View,将这个View添加到当前的控制器

如:

CGFloat timeW = self.view.bounds.size.width;
timeAnimation * timean = [[timeAnimation alloc]initWithFrame:CGRectMake(0,0,timeW,timeW)];
     timean.center = CGPointMake(self.view.bounds.size.width*0.5, self.view.bounds.size.height *0.5);
[self.view addSubview:timean];

第二步:在View的.m文件中添加如下代码

#define PI 3.14159265358979323846

#define kradius self.bounds.size.width*0.1

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.frame = frame;
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}
- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();

    [self greenRound:context];
    self.alpha = 0.5;
    [self test];
}
-(void)test
{
    // 2.创建缩放动画对象
    CABasicAnimation *scale = [CABasicAnimation animation];
    scale.keyPath = @"transform.scale";
    scale.fromValue =[NSNumber numberWithFloat:0.0];
    scale.toValue =[NSNumber numberWithFloat:1.0];
    CABasicAnimation *scale1 = [CABasicAnimation animation];
    scale1.keyPath = @"opacity";
    scale1.fromValue =[NSNumber numberWithFloat:1.0];
    scale1.toValue =[NSNumber numberWithFloat:0.0];
    // 4.将所有的动画添加到动画组中
    CAAnimationGroup *group = [CAAnimationGroup animation];
    group.animations = @[scale,scale1];
    group.duration =.6;
    group.repeatCount = HUGE_VALF;
    group.removedOnCompletion = NO;
    group.fillMode = kCAFillModeForwards;
    [self.layer addAnimation:group forKey:nil];
}
/**画绿色的圆*/
-(void)greenRound:(CGContextRef)context
{
    CGContextSetRGBStrokeColor(context, 33/255.0, 177/255.0, 75/255.0, 1);//画笔线的颜色
    CGContextSetLineWidth(context, 4.0);//线的宽度
    // x,y为圆点坐标,radius半径,startAngle为开始的弧度,endAngle为 结束的弧度,clockwise 0为顺时针,1为逆时针。
    CGContextAddArc(context, self.bounds.size.width *0.5,self.bounds.size.height*0.5,self.bounds.size.width*0.21, 0, 2*PI, 0); //添加一个圆
    CGContextDrawPath(context, kCGPathStroke); //绘制路径
}
时间: 2024-07-29 17:50:08

iOS 圆的放大动画效果的相关文章

IOS视图缩放显示动画效果

效果:视图从大--小缩放显示/小--大 (只是比例问题) 方法1.直接show出view的时候:把下面的这段代码加到viewController或者view出现的时候就OK self.view.transform = CGAffineTransformMakeScale(1.0f, 1.0f);//将要显示的view按照正常比例显示出来  [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];  [UIView se

css3伪放大镜(图片放大动画)效果(鼠标移入圆形区域放大图片)

源码: <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>css3伪放大镜(图片放大动画)效果</title><style>.gallery{list-style:none}.gallery:before,.gallery__item:last-child{position:fixed;top:50

iOS开发 QQ粘性动画效果

QQ(iOS)客户端的粘性动画效果 时间 2016-02-17 16:50:00  博客园精华区 原文  http://www.cnblogs.com/ziyi--caolu/p/5195615.html 主题 iOS开发 qq的app中要是有新的联系人发消息过来,相应联系人的cell右边会有一个红色的圆圈表示消息条数.如果去触碰那个圆圈,可以发现它竟然会跟着手指的移动而移动. 在一定范围内,手指离开屏幕,会发现红色圆圈会自动弹性的回到原来的位置.而如果超出一定距离,这个圆圈会做一个销毁的动画,

轻松实现Android,iOS的一个手势动画效果

先来看效果 这是iOS下的效果,android下完全一致.通过do_GestureView组件和do_Animation组件,deviceone能很容易实现复杂的跨平台纯原生动画效果,这个示例就是通过手势控制图片上下动画滑动实现开合效果,还支持声音效果. 下面是主要的代码 //index.ui.js var do_Animator1 = mm("do_Animator"); do_Animator1.append(500, { y: -1334, curve:"Linear&

ios开发之--简单动画效果的添加

记录一个简单的动画效果,自己写的,很简单,仅做记录. 附一个demo的下载地址: https://github.com/hgl753951/hglTest.git 代码如下: 1,准备 BOOL _isOpen; NSMutableArray * _btnArray; 2,具体代码 -(void)initUI { _btnArray = [[NSMutableArray alloc]init]; for (int i=0; i<4; i++) { UIButton * btn = [UIButt

iOS开发之吸附动画效果

步骤:1.使用singleviewapplication创建新的项目 2.在.h文件中创建两张图片的实例对象,并与相关的图片进行相连:创建一个UIDynamicAnimator实例对象 3.在.m文件中使用UIAttachmentBehavior创建吸附对象,调用 [UIAttachmentBehavior alloc] initWithItem:<#(nonnull id<UIDynamicItem>)#> attachedToAnchor:<#(CGPoint)#>

[iOS]在tableview中用动画效果改变cell的高度

我们经常会碰到一些需要动画的地方,比如在TOP的发帖页面中,当我们选中一个文本编辑的cell时,cell的高度会动态的改变. 我们要的效果大概就是如下效果: 当我们选择一个cell的时候,我们就要改变它的高度,并且以动画的形式. 我们该如何实现这个效果呢?我们主要需要使用以下这两个方法: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath - (void)ta

iOS开发--UIPickerView的动画效果

开发中用到UIPickerView显示和隐藏的动画.随手记一下 第一步:写一个动画方法 - (void)ViewAnimation:(UIView*)view willHidden:(BOOL)hidden { [UIView animateWithDuration:0.3 animations:^{ if (hidden) { view.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainS

iOS 开发之推力动画效果

步骤: 1.使用single view application 创建新的项目 2.在.h文件中需要遵守两个协议<UICollisionBehaviorDelegate,UIGestureRecognizerDelegate>,使用UIimageview创建一个图片实例对象并与相关图片相连,使用UIDynamicAnimator创建一个动画实例对象,使用UIPushBehavior创建一个推力实例对象,使用cgpoint创建一个实例对象用来记录触碰的起始触点,用来确定推力的方向 3.在.m文件中