1

我正在关注本教程“ http://www.raywenderlich.com/6063/uikit-particle-systems-in-ios-5-tutorial ”。一切正常,但我希望这种效果继续出现在我的图像视图中。

请帮助我应该在哪里进行更改

这是我在视图控制器中显示动画的代码

 -(IBAction)ClickOn:(id)sender
{

    [fireView startAnimation];
    [fireView setIsEmitting:YES];
    [self.view bringSubviewToFront:fireView];
    [self.view sendSubviewToBack:sample];

}

这是库视图类中的代码

    -(void)startAnimation
{
    NSLog(@"awakeFromNib");
    //set ref to the layer
    fireEmitter = (CAEmitterLayer*)self.layer; //2

    //configure the emitter layer
    fireEmitter.emitterSize = CGSizeMake(20, 20);


    CAEmitterCell* fire = [CAEmitterCell emitterCell];

    fire.birthRate = 0;
    fire.lifetime = 2.0;
    fire.lifetimeRange = 1.5;

    fire.color = [[UIColor colorWithRed:236 green:237 blue:237 alpha:0.1] CGColor];
    fire.contents = (id)[[UIImage imageNamed:@"Particles_fire.png"] CGImage];
    [fire setName:@"fire"];
    fire.yAcceleration =
    fire.velocity = 0.1;
    fire.velocityRange = 80;
    fire.emissionRange = 80;
    fire.scale = 1.0;
    fire.scaleSpeed = 0.1;
    fire.spin = 40.5;

    CABasicAnimation* ba = [CABasicAnimation animationWithKeyPath:@"emitterPosition"];
    ba.fromValue = [NSValue valueWithCGPoint:CGPointMake(150, 400)];
    ba.toValue = [NSValue valueWithCGPoint:CGPointMake(300,0)];
    ba.duration = 6;
    ba.autoreverses = NO;

    [fireEmitter addAnimation:ba forKey:nil];

    fireEmitter.renderMode = kCAEmitterLayerPoints;

    //add the cell to the layer and we're done
    fireEmitter.emitterCells = [NSArray arrayWithObject:fire];
    fireEmitter.zPosition = 400.0;

}

基本上我只想让动画超过 uiimageview 或 uiview,目前它在后面

4

0 回答 0