我正在尝试将淡入淡出应用于我在另一个上面以编程方式创建的UIView.
[UIView animateWithDuration:0.5 animations:^(void) {
[self.view setAlpha:0];
}
completion:^(BOOL finished){
[self.view removeFromSuperview];
}];
Run Code Online (Sandbox Code Playgroud)
完成的事件在0.5秒之后被正确调用,但我没有看到任何淡入淡出(我应该看到底部的UIView).
如果不使用alpha,我会移开UIView它可以工作(我看到底部UIView,而顶部UIView滑落),所以它似乎是一个与alpha相关的问题,但我无法弄清楚什么是错的!
[UIView animateWithDuration:0.5 animations:^(void) {
CGRect o = self.view.frame;
o.origin.x = 320;
self.view.frame = o;
}
completion:^(BOOL finished){
[self.view removeFromSuperview];
}];
Run Code Online (Sandbox Code Playgroud)
我之前使用过alpha动画,它们通常以这种方式工作......