SoFunction
Updated on 2025-04-10

iOS implements background Gaussian blur effect

Without further ado, implement simple Gaussian fuzzy effect code:

  UIView *bgview= [[UIViewalloc]initWithFrame:];
//   = [UIColor blackColor];
//   = 0.9;
   =10086;
  [:bgview];
  UIBlurEffect *blur = [UIBlurEffecteffectWithStyle:UIBlurEffectStyleLight];
  UIVisualEffectView *effectview = [[UIVisualEffectViewalloc] initWithEffect:blur];
   =;
  [bgview addSubview:effectview];

This code writing is just a simple implementation of Gaussian fuzzy. Regarding elimination, just remove it.

Regarding the Gaussian blur of the picture, first get the picture:

CIContext *context = [CIContext contextWithOptions:nil]; 
  CIImage *inputImage = [[CIImage alloc] initWithImage:[UIImage imageNamed:@""]]; 
  // create gaussian blur filter 
  CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"]; 
  [filter setValue:inputImage forKey:kCIInputImageKey]; 
  [filter setValue:[NSNumber numberWithFloat:10.0] forKey:@"inputRadius"]; 
  // blur image 
  CIImage *result = [filter valueForKey:kCIOutputImageKey]; 
  CGImageRef cgImage = [context createCGImage:result fromRect:[result extent]]; 
  UIImage *image = [UIImage imageWithCGImage:cgImage]; 
  CGImageRelease(cgImage); 
   = image; 

The above is the vague effect of iOS implementation of Gaussian background that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!