gpt4 book ai didi

iphone - 时间间隔随机。眨眼。通过UIView animateWithDuration :

转载 作者:行者123 更新时间:2023-11-28 23:08:05 25 4
gpt4 key购买 nike

我想创建一个以随机间隔眨眼的动画。就像一个正常人一样,会随机眨眼。

但这不是我想要的,有什么想法吗?

- (void)animateFrogEyeOpenClose
{
if (OpenEye) {
[UIView animateWithDuration:0.1

animations:^{
eyeOpenImageView.alpha = 0.0;
eyeCloseImageView.alpha = 1.0;
}
completion:^(BOOL completed){
if (completed)
OpenEye = 0;
CloseEye = 1;
[self animateFrogEyeOpenClose];
}
];
}
else
{
[UIView animateWithDuration:0.1

animations:^{
eyeOpenImageView.alpha = 1.0;
eyeCloseImageView.alpha = 0.0;
}
completion:^(BOOL completed){
if (completed)
OpenEye = 1;
CloseEye = 0;
[self animateFrogEyeOpenClose];
}
];
}
}

最佳答案

为什么不在随机时间后触发此方法???喜欢

//call this method for the first time 
[self fireMethod:nil];
//

- (void)fireMethod:(id)sender{
int rand = arc4random(); //set the random no acc. to your requirement
[self animateFrogEyeOpenClose];
[self performSelector:@selector(fireMthod:) withObject:nil afterDelay:rand];
}

关于iphone - 时间间隔随机。眨眼。通过UIView animateWithDuration :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8891009/

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