我對Objective-C非常陌生,剛剛從頭開始製作我的第一個應用程序。這是一個拼寫應用程序,如果用戶輸入錯誤的字母,我想顯示屏幕上顯示的相同白色閃光。我會怎麼做?向用戶顯示「截圖閃光燈」作爲反饋
3
A
回答
5
// Create a empty view with the color white.
UIView *flashView = [[UIView alloc] initWithFrame:window.bounds];
flashView.backgroundColor = [UIColor whiteColor];
flashView.alpha = 1.0;
// Add the flash view to the window
[window addSubview:flashView];
// Fade it out and remove after animation.
[UIView animateWithDuration:0.05 animations:^{ flashView.alpha = 0.0; } completion:^(BOOL finished) { [flashView removeFromSuperview]; } ];
1
一個簡單的方法是在當前視圖(或UIWindow
)上將白色UIView
的alpha設置爲0。然後,應用閃光效果,可能是這樣的:
-(void)flashEffect {
// Show it suddenly
[self.flashSubview setAlpha:1.0];
// Fade it out
[UIView animateWithDuration:0.5
animations:^{
[self.flashSubview setAlpha:0.0];
}
completion:^(BOOL finished){}];
}
1
一切的頂部添加全屏白色UIView
和動畫的透明度。
// Create a fullscreen, empty, white view and add it to the window.
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *flashView = [[UIView alloc] initWithFrame:window.bounds];
flashView.backgroundColor = [UIColor whiteColor];
flashView.alpha = 1.0f;
[window addSubview:flashView];
// Fade it out and remove after animation.
[UIView animateWithDuration:0.05f animations:^{
flashView.alpha = 0.0f;
} completion:^(BOOL finished) {
[flashView removeFromSuperview];
}];
+0
的方式,這是完美的,謝謝:) –
相關問題
- 1. 顯示閃光燈
- 2. swfobject - 閃光燈未顯示
- 3. Rails - 協會,用戶對用戶的反饋 - 顯示反饋
- 4. 閃光燈爲Android
- 5. 顯示以上內容的閃光燈
- 6. 在閃光燈上顯示cookie值
- 7. 遙控閃光燈演示
- 8. 用戶反饋的數據顯示
- 9. 閃光燈消息不顯示重定向後
- 10. 使用閃光燈
- 11. 使用閃光燈
- 12. 閃光燈
- 13. 閃光燈
- 14. 當通過ajax加載內容時向用戶顯示反饋
- 15. 反編譯的Android APK閃光燈
- 16. 閃光燈 - 離線 - 多個用戶
- 17. 用戶界面閃光燈AS 3.0
- 18. 如何使用閃光燈而不停止相機饋送?
- 19. 簡單的燈箱反饋表格?包含屏幕截圖
- 20. 使用AC_FL_RunContent嵌入閃光燈僅在IE8中使用閃光作物閃光燈
- 21. 是否可以使用閃光燈將圖像上傳到閃光燈?
- 22. OpenGL ES強光閃光燈
- 23. Android通知閃光燈不起作用
- 24. Qemu閃光燈啓動不起作用
- 25. 不能使用閃光燈的視圖
- 26. 用delphi截圖顯示鼠標光標
- 27. fancybox在閃光燈
- 28. JS帶閃光燈
- 29. 安卓應用閃光燈
- 30. 繪圖心電圖和閃光燈
@DrummerB感謝編輯和改進我的格式化:-) – atxe