我有一点的代码是这样的:为什么在动画块外设置的一些动画属性不起作用?
//up till now someButton's alpha was 1
someButton.alpha = 0;
[UIView animateWithDuration:.25
delay:0.0
options:kMaskEaseOut
animations:^ {
someButton.alpha = 1;
}
completion:^ (BOOL finished){}];
问题是动画开始之前someButton的阿尔法没有设置为0,即没有发生视觉。现在,如果我注释掉整个动画块它的确会someButton的alpha设置为0。另外,如果我这样做:
[UIView animateWithDuration:0
delay:0.0
options:kMaskEaseOut
animations:^ {
someButton.alpha = 0;
} completion:^ (BOOL finished){
[UIView animateWithDuration:.25
delay:0.0
options:kMaskEaseOut
animations:^ {
someButton.alpha = 1;
}
completion:^ (BOOL finished){}];
}];
它工作正常(我开始一个0长度的动画动画后),这有点傻。
Alpha值是浮动的,例如, '1.0f'或'0.0f' – TimD
@TimD,编译器足够智能,可将'int's转换为'float'。 – Ravi