• ios8下添加高斯模糊、ios7创建快照


    1.添加系统高斯模糊

    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"IMG_0004"]];
        imageView.frame = CGRectMake(0, 0,320, 720);
        [self.view addSubview:imageView];
        //ios8下添加高斯模糊,模糊有3种类型
        UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
        effectView.frame = CGRectMake(0, 100, 320, 100);
        [imageView addSubview:effectView];
        //
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
        btn.frame = CGRectMake(10, 50, 100, 40);
        btn.backgroundColor = [UIColor cyanColor];
        [btn setTitle:@"btn" forState:UIControlStateNormal];
        [effectView.contentView addSubview:btn];

     2.添加定制高斯模糊

        //高斯模糊
        CIContext *context = [CIContext contextWithOptions:nil];
        CIImage *inputImage = [[CIImage alloc] initWithImage:[UIImage imageNamed:@"56.jpg"]];
        // 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);
        self.imageView.image = image;

    3.创建快照

    UIImageView    *showView         = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        showView.image = [UIImage imageNamed:@"IMG_0003"];
        [self.view addSubview:showView];
        
        // 截取的view,设置NO透明度为0,Yes透明度为1
        UIView *snap1 = [showView snapshotViewAfterScreenUpdates:NO];
        snap1.center  = self.view.center;
        [self.view addSubview:snap1];
        NSLog(@"alpha=%f",snap1.alpha);
  • 相关阅读:
    软件构造 第七章第三节 断言和防御性编程
    软件构造 第七章第二节 错误与异常处理
    软件构造 第七章第一节 健壮性和正确性的区别
    软件构造 第六章第三节 面向可维护的构造技术
    软件构造 第六章第二节 可维护的设计模式
    欧拉函数代码实现及扩展--快速矩阵幂
    编译原理
    算法设计与分析总结
    人工智能简答总结
    感想
  • 原文地址:https://www.cnblogs.com/huen/p/4527952.html
Copyright © 2020-2023  润新知