這是不太常用到的,記下拉方便自己查找挠进。
模糊效果:
UIImageView *bgImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
? ? bgImageView.image= [UIImageimageNamed:@"bg_image"];
? ? [self.viewaddSubview:bgImageView];
? ? UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
? ? UIVisualEffectView *visualView = [[UIVisualEffectView alloc]initWithEffect:effect];
? ? visualView.frame= bgImageView.bounds;
? ? [bgImageViewaddSubview:visualView];
高斯濾鏡:
CIImage *inputImage = [CIImage imageWithCGImage:[UIImage imageNamed:@"bg_image"].CGImage];
? ? // 2远舅、構(gòu)建一個(gè)濾鏡圖表
? ? CIColor*sepiaColor = [CIColorcolorWithRed:0green:0blue:1.0];
? ? // 2.1 先構(gòu)建一個(gè) CIColorMonochrome 濾鏡锨匆,并配置輸入圖像與濾鏡參數(shù)
? ? CIFilter *inputFilter = [CIFilter filterWithName:@"CIColorMonochrome" withInputParameters:@{@"inputColor":sepiaColor,@"inputIntensity":@0.3}];
? ? [inputFiltersetValue:inputImageforKey:@"inputImage"];
? ? // 2.2 先構(gòu)建一個(gè) CIVignette 濾鏡
? ? CIFilter *vignetteFilter = [CIFilter filterWithName:@"CIVignette" withInputParameters:@{@"inputRadius" : @2.0,@"inputIntensity" :@0.5}];
? ? [vignetteFiltersetValue:inputFilter.outputImageforKey:@"inputImage"];// 以monochromeFilter的輸出來(lái)作為輸入
? ? // 3怔软、得到一個(gè)濾鏡處理后的圖片树酪,并轉(zhuǎn)換至 UIImage
? ? // 創(chuàng)建一個(gè) CIContext
? ? CIContext*ciContext = [CIContextcontextWithOptions:nil];
? ? // 將 CIImage 過(guò)渡到 CGImageRef 類型
? ? CGImageRefcgImage = [ciContextcreateCGImage:vignetteFilter.outputImagefromRect:inputImage.extent];
? ? // 最后轉(zhuǎn)換為 UIImage 類型
? ? UIImage*uiImage = [UIImageimageWithCGImage:cgImage];
? ? UIImageView*imgaeView = [[UIImageViewalloc]initWithImage:uiImage];
? ? imgaeView.frame=self.view.frame;
? ? [self.viewaddSubview:imgaeView];