2011-12-07 51 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]; 

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