最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS實(shí)現(xiàn)毛玻璃效果(無需要第三方)

 更新時(shí)間:2018年05月02日 10:40:46   作者:請(qǐng)給我一杯陽光  
這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)毛玻璃效果,無需要第三方,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例分享兩種iOS毛玻璃效果設(shè)置的方法,不需要任何第三方,先看效果:

原圖:

方法一(iOS8系統(tǒng)方法):

方法二:

下面是示例代碼:

#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]; 
 
 //方法一:系統(tǒng)方法,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 

具體效果和參數(shù)自行研究吧!

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

南城县| 隆化县| 德清县| 兴安盟| 芦山县| 策勒县| 聊城市| 普安县| 兴业县| 喜德县| 增城市| 昭苏县| 任丘市| 德昌县| 青浦区| 鄂伦春自治旗| 邛崃市| 罗山县| 南昌县| 乌兰县| 门源| 连州市| 清远市| 洮南市| 射洪县| 集安市| 井研县| 凤阳县| 桐梓县| 肇源县| 山丹县| 长沙县| 九龙城区| 鲜城| 安仁县| 仙居县| 渝北区| 孝感市| 平乡县| 新泰市| 吉木乃县|