gpt4 book ai didi

iphone - UILabel淡入淡出问题

转载 作者:行者123 更新时间:2023-12-03 20:21:32 25 4
gpt4 key购买 nike

我在 NSTimer 选择器中得到了以下代码:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:0];
[UIView commitAnimations];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:1];
[UIView commitAnimations];

所以我想在 UILabel (infoLbl) 上实现一个简单的淡入/淡出循环。

好吧,通过这段代码,我只得到了淡入步骤,因为 UILabel 突然消失,然后淡入。

有什么建议吗?

谢谢。

最佳答案

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:0];
[UIView commitAnimations];

//This delegate is called after the completion of Animation.
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:1];
[UIView commitAnimations];

}

插入此内容,如果您使用 NStimer Selecor,那么您不尝试更改 uilabel 文本的颜色吗?像:

-(void)timerSelector
{
if([textLabel textColor] == [UIColor blackColor])
{
[textLabel setTextColor:[UIColor grayColor]];
}
else
{
[textLabel setTextColor:[UIColor blackColor]];
}
}

上述方法将使您能够轻松地循环淡入/淡出。

关于iphone - UILabel淡入淡出问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2591363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com