4
A
回答
6
白色的全屏幕的UIView添加到窗口和動畫它的α(與持續時間和動畫曲線發揮得結果是你想要的):
-(void) flashScreen {
UIWindow* wnd = [UIApplication sharedApplication].keyWindow;
UIView* v = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, wnd.frame.size.width, wnd.frame.size.height)] autorelease];
[wnd addSubview: v];
v.backgroundColor = [UIColor whiteColor];
[UIView beginAnimations: nil context: nil];
[UIView setAnimationDuration: 1.0];
v.alpha = 0.0f;
[UIView commitAnimations];
}
編輯:不要忘了刪除視圖之後動畫結束
0
由馬克斯提供的答案相似,但使用的UIView animateWithDuration代替
- (void)flashScreen {
// Make a white view for the flash
UIView *whiteView = [[UIView alloc] initWithFrame:self.view.frame];
whiteView.backgroundColor = [UIColor whiteColor];
whiteView.alpha = 1.0; // Optional, default is 1.0
// Add the view
[self.view addSubview:whiteView];
// Animate the flash
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationOptionCurveEaseOut // Seems to give a good effect. Other options exist
animations:^{
// Animate alpha
whiteView.alpha = 0.0;
}
completion:^(BOOL finished) {
// Remove the view when the animation is done
[whiteView removeFromSuperview];
}];
}
有不同的版本animateW的ithDuration,如果您不需要延遲並且可以使用默認的動畫選項,那麼您也可以使用這個較短的版本。
[UIView animateWithDuration:1.0
animations:^{
// Animate alpha
whiteView.alpha = 0.0;
}
completion:^(BOOL finished) {
// Remove the view when the animation is done
[whiteView removeFromSuperview];
}];
相關問題
- 1. 以編程方式閃爍屏幕
- 2. (Java)屏幕閃爍
- 3. iOSBetaBuilder +屏幕閃爍
- 4. 如何讓閃爍的屏幕閃爍_ swift 3
- 5. 如何阻止angularJs閃爍屏幕
- 6. 如何避免屏幕閃爍?
- 7. 閃爍的屏幕ALLEGRO 5
- 8. node-webkit屏幕閃爍
- 9. 屏幕閃爍在Response.redirect
- 10. SetDeviceGammaRamp只是閃爍屏幕
- 11. 閃爍的屏幕 - pygame
- 12. 屏幕閃爍問題
- 13. pygame閃爍屏幕修復
- 14. 如何使按鈕以編程方式按順序閃爍
- 15. 以屏幕截圖(以編程方式)
- 16. 在Windows中,如何以編程方式使我的整個屏幕閃爍黑白?
- 17. 如何在Android中以編程方式截屏整個屏幕?
- 18. 鎖定屏幕以編程方式
- 19. 以編程方式觸摸屏幕phonegap
- 20. Android屏幕以編程方式打開
- 21. 以編程方式關閉iOS屏幕
- 22. 以編程方式打開屏幕
- 23. 以編程方式進入主屏幕
- 24. 在桌面模式下,libgdx如何修復閃爍屏幕?
- 25. 模糊查找 - DOS屏幕以32位模式閃爍
- 26. 使屏幕閃爍/閃爍提醒用戶
- 27. 以編程方式拍攝整個屏幕的屏幕截圖
- 28. 以編程方式屏幕屏幕的某些部分
- 29. 如何以編程方式安裝屏幕保護程序?
- 30. 如何以編程方式更改屏幕保護程序?
也不要忘記釋放的一切,當你做:) – 2011-03-10 02:02:32
這是驚人的快和正確的答案。多謝Max! – Patryk 2011-03-10 02:05:46