UIVisualEffectView(高斯模糊效果)

   ///高斯模糊。
   UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; tempView.backgroundColor = [UIColor yellowColor]; [self.view addSubview:tempView]; ///UIBlurEffectStyleExtraLight聚光灯效果。UIBlurEffectStyleLight效果轻。UIBlurEffectStyleDark效果重。 UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; effectView.frame = CGRectMake(100, 100, 100, 100); ///作用对tempView做高斯模糊效果。 [self.view addSubview:effectView];

将UIBackgroundTaskIdentifier设置为UIBackgroundTaskInvalid即后台任务已关闭。

 1 - (void)applicationDidEnterBackground:(UIApplication *)application {
 2     //由于要取消后台任务,所以需要后台任务标识符 。
 3     _identifier = [application beginBackgroundTaskWithExpirationHandler:^{
 4           [self endTask]; // 如果在系统规定时间内任务还没有完成,在时间到之前会调用到这个方法,一般是10分钟
 5     }];
 6     
 7     [self performSelector:@selector(endTask) withObject:self afterDelay:120];
 8 }
 9 
10 - (void)endTask{
11     [[UIApplication sharedApplication] endBackgroundTask:_identifier];
12     _identifier = UIBackgroundTaskInvalid;
13 }
原文地址:https://www.cnblogs.com/jisa/p/6843869.html