iOS实现毛玻璃效果(无需要第三方)

iOS实现毛玻璃效果(无需要第三方),第1张

概述iOS实现毛玻璃效果(无需要第三方) 本文实例分享两种iOS毛玻璃效果设置的方法,不需要任何第三方,先看效果: 原图: 方法一(iOS8系统方法): 方法二: 下面是示例代码: #import "ViewController.h" @interface ViewController () { UIImageView *_imageView; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; _image ...

本文实例分享两种iOS毛玻璃效果设置的方法,不需要任何第三方,先看效果:

原图:

方法一(iOS8系统方法):

方法二:

下面是示例代码:

#import "VIEwController.h" @interface VIEwController (){ UIImageVIEw *_imageVIEw;}@end @implementation VIEwController - (voID)vIEwDIDLoad { [super vIEwDIDLoad]; _imageVIEw = [[UIImageVIEw alloc]initWithFrame:self.vIEw.bounds]; _imageVIEw.image = [UIImage imagenamed:@"1.jpg"]; [self.vIEw addSubvIEw:_imageVIEw];  //方法一:系统方法,iOS8及以上可用 if (!UIAccessibilityIsReduceTransparencyEnabled()) { UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; UIVisualEffectVIEw *blurEffectVIEw = [[UIVisualEffectVIEw alloc]initWithEffect:blurEffect]; blurEffectVIEw.frame = _imageVIEw.bounds; [_imageVIEw addSubvIEw:blurEffectVIEw]; }  //方法二:Core Image UIImageVIEw *blurImageVIEw = [[UIImageVIEw alloc]initWithFrame:_imageVIEw.bounds]; blurImageVIEw.image = [self blur:[UIImage imagenamed:@"1.jpg"]]; [_imageVIEw addSubvIEw:blurImageVIEw];} //生成一张毛玻璃图片- (UIImage*)blur:(UIImage*)theImage{ CIContext *context = [CIContext contextWithOptions:nil]; CIImage *inputimage = [CIImage imageWithCGImage:theImage.CGImage];  CIFilter *filter = [CIFilter filterWithname:@"CIGaussianBlur"]; [filter setValue:inputimage forKey:kCIInputimageKey]; [filter setValue:[NSNumber numberWithfloat:15.0f] forKey:@"inputRadius"]; CIImage *result = [filter valueForKey:kCIoUtputimageKey];  CGImageRef cgImage = [context createCGImage:result fromrect:[inputimage extent]];  UIImage *returnImage = [UIImage imageWithCGImage:cgImage]; CGImageRelease(cgImage); return returnImage;} - (voID)dIDReceiveMemoryWarning { [super dIDReceiveMemoryWarning]; // dispose of any resources that can be recreated.} @end 

具体效果和参数自行研究吧!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

您可能感兴趣的文章:AndroID中实现iOS中的毛玻璃效果iOS自定义collectionVIEw实现毛玻璃效果IOS图片设置毛玻璃效果iOS毛玻璃效果的实现及图片模糊效果的三种方法iOS7 毛玻璃特效代码iOS 8使用UIBlurEffect实现毛玻璃特效 总结

以上是内存溢出为你收集整理的iOS实现毛玻璃效果(无需要第三方)全部内容,希望文章能够帮你解决iOS实现毛玻璃效果(无需要第三方)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1110011.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存