如何为iOS UILabel实现选框?
谢谢!
答案 0 :(得分:3)
我不太确定,但我认为你必须按帧进行动画。当你设置标签的坐标时,把变量设置为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];
我希望它可以帮助你...... :)