美文网首页固予
iOS雪花动画

iOS雪花动画

作者: Realank | 来源:发表于2016-03-15 09:16 被阅读312次
    雪花效果
        //create particle emitter layer
        CAEmitterLayer *emitter = [CAEmitterLayer layer];
        emitter.frame = CGRectMake(0, -50, self.view.bounds.size.width, 50);
        [self.view.layer addSublayer:emitter];
        
        emitter.emitterShape = kCAEmitterLayerRectangle;
        //configure emitter
    //    emitter.renderMode = kCAEmitterLayerAdditive;
        emitter.emitterPosition = CGPointMake(emitter.frame.size.width / 2.0, emitter.frame.size.height / 2.0);
        emitter.emitterSize = emitter.frame.size;
        
        //create a particle template
        CAEmitterCell *cell = [[CAEmitterCell alloc] init];
        cell.contents = (__bridge id)[UIImage imageNamed:@"snow"].CGImage;
        cell.contentsScale = 7;
        
        cell.birthRate = 100;
        cell.lifetime = 5.0;
        cell.lifetimeRange = 5;
        
        cell.redRange = 0.1;
        cell.greenRange = 0.1;
        cell.blueRange = 0.1;
        
        cell.alphaRange = 0.8;
        cell.alphaSpeed = -0.10;
        
        cell.yAcceleration = 30;
        cell.xAcceleration = 20;
        cell.velocity = 20;
        cell.velocityRange = 200;
        cell.emissionRange = M_PI_2;
        cell.emissionLongitude = - M_PI;
        
        //add particle template to emitter
        emitter.emitterCells = @[cell];
    

    相关文章

      网友评论

        本文标题:iOS雪花动画

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