1、UIToolbar 模糊效果不受控制
UIToolbar *blurView = [[UIToolbar alloc] init];
blurView.barStyle = UIBarStyleBlack;
[_headImgView addSubview:blurView];
2、高斯模糊处理
+(UIImage *)coreBlurImage:(NSString *)imageUrl withPlaceholderImage:(UIImage *)plaImg withBlurNumber:(CGFloat)blur
{
UIImage *changeImg;
if(imageUrl.length > 0)//网络图片
{
NSURL *url =[NSURL URLWithString:imageUrl];
NSData *tempData =[NSData dataWithContentsOfURL:url];
changeImg = [UIImage imageWithData:tempData]; // 取得图片
}
else//本地图片
{
changeImg = plaImg;
}
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *inputImage= [CIImage imageWithCGImage:changeImg.CGImage];
//设置filter
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
[filter setValue:inputImage forKey:kCIInputImageKey];
[filter setValue:@(blur) forKey: @"inputRadius"];
//模糊图片
CIImage *result=[filter valueForKey:kCIOutputImageKey];
// CGImageRef outImage=[context createCGImage:result fromRect:[result extent]];
CGImageRef outImage = [context createCGImage: result fromRect:[inputImage extent]];
UIImage *blurImage=[UIImage imageWithCGImage:outImage];
CGImageRelease(outImage);
return blurImage;
}
原文:http://www.cnblogs.com/huaixu/p/6708493.html