• iOSS--生成有logo的二维码


    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        self.imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 50, 400, 400)];
        [self.view addSubview:_imageview];
        [self createLogoImage];
    }
    
    - (void)createLogoImage {
        NSArray *filter = [CIFilter filterNamesInCategory:kCICategoryBuiltIn];
        NSLog(@"%@", filter);
        // 二维码过滤器
        CIFilter *filterImage = [CIFilter filterWithName:@"CIQRCodeGenerator"];
        // 将二位码过滤器设置为默认属性
        [filterImage setDefaults];
        // 将文字转化为二进制
        NSData *dataImage = [@"mafeng" dataUsingEncoding:NSUTF8StringEncoding];
        // 打印输入的属性
        NSLog(@"%@", filterImage.inputKeys);
        // KVC 赋值
        [filterImage setValue:dataImage forKey:@"inputMessage"];
        // 取出输出图片
        CIImage *outputImage = [filterImage outputImage];
        outputImage = [outputImage imageByApplyingTransform:CGAffineTransformMakeScale(20, 20)];
        // 转化图片
        UIImage *image = [UIImage imageWithCIImage:outputImage];
        
        // **********为二维码加自定义图片***********
        
        // 开启绘图, 获取图片 上下文<图片大小>
        UIGraphicsBeginImageContext(image.size);
        // 将二维码图片画上去
        [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
        // 将小图片画上去
        UIImage *smallImage = [UIImage imageNamed:@"123.jpg"];
        [smallImage drawInRect:CGRectMake((image.size.width - 100) / 2, (image.size.width - 100) / 2, 100, 100)];
        // 获取最终的图片
        UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
        // 关闭上下文
        UIGraphicsEndImageContext();
        // 显示
        self.imageview.image = finalImage;
    }

    效果展示:

  • 相关阅读:
    火狐中添加selenium IDE
    loadrunner 手动添加关联
    loadrunner11完整卸载
    phpstudy后门交互式shell
    selenium+python Douyu弹幕机器人
    HTTP头sleep延迟注入
    DDCTF-2019
    感知器
    校园网破解
    pwn-格式化字符串漏洞
  • 原文地址:https://www.cnblogs.com/mafeng/p/5864696.html
Copyright © 2020-2023  润新知