zoukankan      html  css  js  c++  java
  • iOS—雪花飘落动画效果

    //
    //  HMview.h
    //  雪花飘落效果
    //
    //  Created by YaguangZhu on 15/9/9.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface HMview : UIView
    
    @end
    
    
    //
    //  HMview.m
    //  雪花飘落效果
    //
    //  Created by YaguangZhu on 15/9/9.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import "HMview.h"
    @interface HMview()
    
    @property(nonatomic,assign)CGFloat snowY;
    
    @end
    
    @implementation HMview
    
    - (void)awakeFromNib
    {
    //    [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(setNeedsDisplay) userInfo:nil repeats:YES];
        
        CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)];
        [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
    }
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    - (void)drawRect:(CGRect)rect {
        // Drawing code
        _snowY += 10;
        UIImage *imgae = [UIImage imageNamed:@"003"];
        [imgae drawAtPoint:CGPointMake(0, _snowY)];
        if (_snowY >= 480) {
            _snowY =0;
        }
        
    }
    
    
    @end
  • 相关阅读:
    spark实验四(2)
    spark实验四
    神奇的一天
    Spark实验三
    Scala实验任务三
    Scala实验任务二
    Scala语言实验任务一
    kettle的基本使用
    质量属性之安全性战术
    datax相关
  • 原文地址:https://www.cnblogs.com/zhuyaguang/p/4795999.html
Copyright © 2011-2022 走看看