美文网首页
iOS 粒子动画 流星效果

iOS 粒子动画 流星效果

作者: 想飞的菜鸟 | 来源:发表于2020-10-23 11:53 被阅读0次

pragma mark -- 流星Animation

  • (void)staranimationWithImageView:(UIImageView *)imageView imagePoint:(CGPoint)point {
    CAEmitterLayer *rainLayer = [CAEmitterLayer layer];
    [rainLayer setEmitterPosition:point];
    [rainLayer setEmitterSize:CGSizeMake(VKLCLength(400), VKLCLength(200))];
    // 发射模式
    [rainLayer setEmitterMode:kCAEmitterLayerLine];
    [rainLayer setEmitterShape:kCAEmitterLayerLine];
    [rainLayer setRenderMode:kCAEmitterLayerAdditive];

    CAEmitterCell *rainCell = [CAEmitterCell emitterCell];
    [rainCell setBirthRate:1];
    [rainCell setVelocity:100];
    [rainCell setXAcceleration:-200];
    [rainCell setYAcceleration:85];
    [rainCell setScale:0.1];
    [rainCell setScaleSpeed:0.2];
    [rainCell setLifetime:1.8];
    [rainCell setEmissionLongitude: 55 * (180.0 / M_PI)];
    [rainCell setContents:(id)[[VKLCImageUtil getImageWithName:@"vklc_starRain"] CGImage]];
    [rainCell setColor:[[UIColor colorWithRed:1 green:1 blue:1 alpha:0.6] CGColor]];

    [rainLayer setEmitterDepth:10];
    rainLayer.emitterCells = [NSArray arrayWithObject:rainCell];
    [imageView.layer addSublayer:rainLayer];
    }

相关文章

网友评论

      本文标题:iOS 粒子动画 流星效果

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