【问题标题】:layer of animation images in iphoneiphone中的动画图像层
【发布时间】:2011-04-11 11:05:10
【问题描述】:

如何在 xcode 上对两组图像进行动画处理?我的意思是一组是背景或风景,另一组是背景中的人物

【问题讨论】:

    标签: objective-c xcode core-animation layer


    【解决方案1】:

    您可以尝试以下基本方法:

    UIImageView* backdropScene = [[UIImageView alloc] initWithFrame:self.view.frame];
    
    backdropScene.animationImages = [NSArray arrayWithObjects:    
    [UIImage imageNamed:@"rainy_background01.png"],
    [UIImage imageNamed:@"rainy_background02.png"],
    [UIImage imageNamed:@"rainy_background03.png"],
    [UIImage imageNamed:@"rainy_background04.png"], nil];
    
    backdropScene.animationDuration = .2f; // image change rate, .2 seconds
    backdropScene.animationRepeatCount = 0; // repeat infinitely
    [self.view addSubview:backdropScene];
    [backdropScene startAnimation];
    
    
    UIImageView* foregroundAnimation = [[UIImageView alloc] initWithFrame:self.view.frame];
    
    foregroundAnimation.animationImages = [NSArray arrayWithObjects:    
    [UIImage imageNamed:@"man_walk01.png"],
    [UIImage imageNamed:@"man_walk02.png"],
    [UIImage imageNamed:@"man_walk03.png"],
    [UIImage imageNamed:@"man_walk04.png"], nil];
    
    foregroundAnimation.animationDuration = .5f; // image change rate, .2 seconds
    foregroundAnimation.animationRepeatCount = 0; // repeat infinitely
    [self.view addSubview:foregroundAnimation];
    [foregroundAnimation startAnimation];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-22
      • 1970-01-01
      相关资源
      最近更新 更多