我开始使用UIView动画。并且无法使这些代码正常工作。这就是我所拥有的
if(_Language.hidden == true)
{
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
_Language.alpha = 1.0;
}
completion:^(BOOL finished) {
_Language.hidden = false;
}];
}
else
{
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
_Language.alpha = 0.0;
}
completion:^(BOOL finished) {
_Language.hidden = true;
}];
}
此代码以这种方式工作。隐藏动画按预期工作。但是显示动画只等待1秒,然后弹出对象而没有任何过渡。谁能告诉我这里缺少什么?
答案 0 :(得分:9)
仅在动画结束后才将hidden
属性更改为true,因此在动画完成之前不会显示。你应该在动画开始之前做到这一点:
if(_Language.hidden == true)
{
_Language.hidden = false;
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
_Language.alpha = 1.0;
}];
}
答案 1 :(得分:5)
您的_Language.hidden
设置为true
,因此在动画制作时,屏幕上不会显示任何内容。您需要在动画制作之前使其可见。将hidden属性设置为false,然后显示动画。反向将仅在您在完成块中添加时隐藏。
_Language.hidden = false;
[UIView animateWithDuration:1.0 ...
并将其从完成块中删除,
completion:^(BOOL finished) {
}];