美文网首页
水柱动画

水柱动画

作者: lichengjin | 来源:发表于2016-04-11 23:13 被阅读111次

#import<UIKit/UIKit.h>

@interface SDmoreCicle : UIView

//水柱的实现

+(instancetype)ViewWithCicle:(CGRect)rect;

-(instancetype)initWithFrame:(CGRect)frame;

@end

#import "SDmoreCicle.h"

@implementation SDmoreCicle

+(instancetype)ViewWithCicle:(CGRect)rect

{

  return [[self alloc] initWithFrame:rect];

}

-(instancetype)initWithFrame:(CGRect)frame

{

    return [super initWithFrame:frame];

}

-(void)createCicle:(NSSet *)touches

{

    //第一次触碰

    UITouch *touch = [touches anyObject];

    //获取触碰的点

    CGPoint point = [touch locationInView:self];

    //初始化层

    CALayer *layer = [CALayer layer];

    //设置层是尺寸

    layer.frame = CGRectMake(point.x-1, point.y-1, 10, 10);

        //设置水柱的颜色

    layer.borderColor = [UIColor colorWithRed:arc4random()%243/64.0 green:arc4random()%230/100.0 blue:arc4random()%89/200.0 alpha:1].CGColor;    //设置水柱的边框宽度

    layer.borderWidth = 0.5;

    //设置水柱的倒圆角

    layer.cornerRadius = 5;

    //设置动画

    [self setAnimation:layer];

        [self.layer addSublayer:layer];

    }

-(void)setAnimation:(CALayer *)layer

{

    const int max = 20;

    if (layer.transform.m11 < max)

{

      //3D动画

      [layer setTransform:CATransform3DScale(layer.transform, 1.1, 1.1, 1.0)];        //动画延时

        //_cmd获取当前方法的名称

        [self performSelector:_cmd withObject:layer afterDelay:0.03];

    } else {

        //删除layer

        [layer removeFromSuperlayer];

    }

}

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event

{

    [self createCicle:touches];

}

-(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent *)event

{

[self createCicle:touches];

}

@end

#import<UIKit/UIKit.h>

#import "SDmoreCicle.h"

@interface ViewController : UIViewController

@end

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

self.view.backgroundColor = [UIColor grayColor];

[self.view addSubview:[SDmoreCicle ViewWithCicle:self.view.frame]];

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

效果图:

相关文章

  • 水柱动画

    #import @interface SDmoreCicle : UIView //水柱的实现 +(instanc...

  • 水柱

    乘着狂躁的暴风乌云旋成水柱笔直向上本可以傲视群雄为了满足被欣赏的欲望弯曲成彩色的虹 2022年8月31日

  • 白水柱情缘

    说下我为啥对白水晶柱情有独钟吧!在2013年6月份在北京参加完《生命之花灵性法制》工作坊之后回家,当我走进家中一个...

  • 用爱心烹制生活的盛宴

    钢琴声缓缓响起,优雅悦耳;蓝白相间的小方瓷砖,三角形的水柱环绕着圆形水柱,水柱随着音乐的声音忽高忽低,忽上忽下,灯...

  • Day 18 水柱光影

    晚上上了回博物馆的房顶,月牙朦胧,下面的水柱应着夕阳闪闪发光,不过夜晚的清晰度和调光真难呀手机党表示摊手...

  • 消火栓水枪充实水柱

    定义 充实水柱长度:水枪射流中在26mm-28mm直径圆断面内,包含全部水量75%-90%的密实水柱长度。 重要性...

  • 大千传(181)斗鱼王

    第181章 斗鱼王 赵夭夭长剑雷光闪动,剑气封住了周身,初韭施展罗汉金身,被水柱击退数米。 水柱触碰雷光,被雷电引...

  • Android自定View水柱刻度

    库信息 包名:com.water.spout库名称:watercolumnviewspoutviewtubevie...

  • 半杯水

    我把水轻轻倒入杯子,柔顺,如丝如绸,一倾而下。 水柱拥入杯内,夹着水泡,仿佛能听见咕噜噜的声音,但是水柱太小,在这...

  • 洗澡?免谈!

    题记:真是猫落尘世被人欺,快把那个水柱挪开! ----------------------------------...

网友评论

      本文标题:水柱动画

      本文链接:https://www.haomeiwen.com/subject/hgiilttx.html