gpt4 book ai didi

iphone - 显示 UILabel 动画

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:53:40 25 4
gpt4 key购买 nike

我需要显示一条消息,该消息随动画一起出现,并在几秒钟后也随动画一起隐藏。

有谁知道这是怎么可能的?

非常感谢你所做的一切。

问候

最佳答案

这很简单,尝试将您的动画链接在一起。先淡入,再淡出。下面的代码首先将 alpha 设置为 0。然后在 1 秒内为标签的外观设置动画。完成后,等待 4 秒,然后以相同方式启动淡出动画。

[label setText:@"some text"];
[label setAlpha:0.0];
[UIView animateWithDuration:1.0
delay:0
options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
animations:^(void)
{
[label setAlpha:1.0];
}
completion:^(BOOL finished)
{
if(finished)
{
[UIView animateWithDuration:1.5
delay:4
options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
animations:^(void)
{
[label setAlpha:0.0];
}
completion:^(BOOL finished)
{
if(finished)
NSLog(@"Hurray. Label fadedIn & fadedOut");
}];
}
}];

这种在 iOS 中链接动画的方式是最有效的方式之一。

关于iphone - 显示 UILabel 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9603165/

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