Objective c 显示";截图快闪“;作为对用户的反馈
我对Objective-C非常陌生,刚刚从零开始制作了我的第一个应用程序。这是一个拼写应用程序,如果用户输入了错误的字母,我想在截图时显示屏幕上显示的白色闪光。我该怎么做呢?一个简单的方法是在当前视图(或Objective c 显示";截图快闪“;作为对用户的反馈,objective-c,ios,Objective C,Ios,我对Objective-C非常陌生,刚刚从零开始制作了我的第一个应用程序。这是一个拼写应用程序,如果用户输入了错误的字母,我想在截图时显示屏幕上显示的白色闪光。我该怎么做呢?一个简单的方法是在当前视图(或UIWindow)上设置一个白色UIView,alpha设置为0。然后,应用闪光效果,可以是这样的: -(void)flashEffect { // Show it suddenly [self.flashSubview setAlpha:1.0]; // Fade it
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){}];
}
在所有内容的顶部添加一个全屏白色
ui视图
,并设置其alpha动画
// 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];
}];
@鼓手感谢编辑和改进我的格式:-)这太完美了,谢谢:)
// 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]; } ];