2011-12-07 49 views

回答

3

我不是很确定,但我认为你必须通过frame.when来做动画。当你设置标签的坐标放置变量像x,y而不是参数1和2的值,并把这个在一个动画计时器中改变x和y的值。

类似的代码,它是图像可以为标签做到这一点也: - 对于简单的问题

// Build array of images, cycling through image names 
    for (int i = 0; i < IMAGE_COUNT; i++) 
    [imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"Frame_%d.jpg", i]]]; 

    // Animated images - centered on screen 
    animatedImages = [[UIImageView alloc] 
    initWithFrame:CGRectMake(
     (SCREEN_WIDTH/2) - (IMAGE_WIDTH/2), 
     (SCREEN_HEIGHT/2) - (IMAGE_HEIGHT/2) + STATUS_BAR_HEIGHT, 
     IMAGE_WIDTH, IMAGE_HEIGHT)]; 
    animatedImages.animationImages = [NSArray arrayWithArray:imageArray]; 

    // One cycle through all the images takes 1.5 seconds 
    animatedImages.animationDuration = 1.0; 

    // Repeat forever 
    animatedImages.animationRepeatCount = -1; 

    // Add subview and make window visible 
    [window addSubview:animatedImages]; 
    [window makeKeyAndVisible]; 

    // Start it up 
    animatedImages.startAnimating; 

    // Wait 5 seconds, then stop animation 
    [self performSelector:@selector(stopAnimation) withObject:nil afterDelay:1000]; 

我希望它可以帮助你.. :)