自己封装的方法:
+(void)showScoreInWindow:(NSString *)score showTimeValue:(CGFloat)time
{
UIWindow *window = [UIApplication sharedApplication].delegate.window;
UIView *maskView = [[UIView alloc]initWithFrame:window.bounds];
UIImage *img = [UIImage convertViewToImage:window];
UIImage *blurImg = [img imgWithLightAlpha:0.4 radius:2 colorSaturationFactor:1.8];
maskView.backgroundColor = [UIColor colorWithPatternImage:blurImg];
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"jifen"]];
[imageView sizeToFit];
UILabel *scoreLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, imageView.width_HD, imageView.height_HD)];
scoreLabel.backgroundColor = [UIColor clearColor];
scoreLabel.text = score;
scoreLabel.textAlignment=NSTextAlignmentCenter;
scoreLabel.textColor = [UIColor whiteColor];
scoreLabel.font = [UIFont fontWithName:@"Arial" size:50];
[imageView addSubview:scoreLabel];
imageView.centerX_HD = window.width_HD/2;
imageView.centerY_HD = window.height_HD/2;
[maskView addSubview:imageView];
[window addSubview:maskView];
UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc]initWithTarget:maskView action:@selector(removeFromSuperview)];
tapG.numberOfTapsRequired = 1;
[maskView addGestureRecognizer:tapG];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (maskView) {
[maskView removeFromSuperview];
}
});
}