2011-11-18 39 views
0

我想为UILabel添加一个自动滚动效果。如何在UILabel iPhone SDK中提供选取框效果?

我试图找到在互联网上的任何代码,但没有成功。

部分代码可以在http://blog.stormyprods.com/2009/10/simple-scrolling-uilabel-for-iphone.html找到。所讨论的解决方案通过IBOutlet添加UIScrollview来进行自动滚动。

**我已经编辑了问题,以便给定的部分是更好的理解 - 但问题是,目前还不清楚,恐怕**(至)

+2

帐篷仍然是有史以来最好的HTML标签。我们应该更频繁地使用它! – JustSid

+0

这是iPhone的问题,所以我该如何使用这个uilable。 –

+0

可能重复的[如何将标签添加到标签](http://stackoverflow.com/questions/1118626/how-to-add-marquee-to-a-label) –

回答

1

我不是很肯定,但我认为你有当您为标签设置坐标时,请将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]; 

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

+0

Thanku mac,这帮助我很多。 –

+0

@Rohit: - 你的欢迎亲爱的...... :) – mAc