zoukankan      html  css  js  c++  java
  • IOS 下雪动画修改版本

    #define SNOW_IMAGENAME         @"snow"
    
    #define IMAGE_X                arc4random()%(int)Main_Screen_Width
    #define IMAGE_ALPHA            ((float)(arc4random()%10))/10
    #define IMAGE_WIDTH            arc4random()%20 + 10
    #define PLUS_HEIGHT            Main_Screen_Height/25
    
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    
        [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(makeSnow) userInfo:nil repeats:YES];
    }
    
    - (void)makeSnow
    {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:IMAGENAMED(SNOW_IMAGENAME)];
        float x = IMAGE_WIDTH;
        imageView.frame = CGRectMake(IMAGE_X, -30, x, x);
        imageView.alpha = IMAGE_ALPHA;
        [self.view addSubview:imageView];
        
        [self snowFall:imageView];
    
    }
    
    - (void)snowFall:(UIImageView *)aImageView
    {
        [UIView beginAnimations:[NSString stringWithFormat:@"%i",aImageView.tag] context:nil];
        [UIView setAnimationDuration:6];
        [UIView setAnimationDelegate:self];
        aImageView.frame = CGRectMake(aImageView.frame.origin.x, Main_Screen_Height, aImageView.frame.size.width, aImageView.frame.size.height);
        NSLog(@"%@",aImageView);
        [UIView commitAnimations];
    }
    
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
  • 相关阅读:
    【总结】图论算法
    【算法】Escape
    【算法】哈密顿环绕世界
    【算法】BFS+哈希解决八数码问题
    【算法设计】(综合)博弈树的了解与创建
    【搜索】Shuffle'm Up
    西邮linux兴趣小组2014纳新免试题(一)
    无线路由器入侵实战
    中国移动飞信WAP登陆分析及脚本
    WPA/WPA2加密破解
  • 原文地址:https://www.cnblogs.com/joesen/p/3586690.html
Copyright © 2011-2022 走看看