iOS生成二维码

作者: 静花寒 | 来源:发表于2015-12-24 14:52 被阅读353次

    //生成二维码

    - (void)createCIImageWithText:(NSString*)text

    {

    CIFilter*filter = [CIFilterfilterWithName:@"CIQRCodeGenerator"];

    NSString*string = text;

    NSData*data = [stringdataUsingEncoding:NSUTF8StringEncoding];

    //2.通过kVO设置滤镜传入数据

    [filtersetValue:dataforKey:@"inputMessage"];

    //3.生成二维码

    CIImage*iconImage = [filteroutputImage];

    UIImageView*tempImageView = [[UIImageViewalloc]initWithFrame:(CGRectMake(50,50,100,100))];

    UIImage*image = [UIImageimageWithCIImage:iconImage];

    tempImageView.image= image;

    [self.viewaddSubview:tempImageView];

    }

    相关文章

      网友评论

        本文标题:iOS生成二维码

        本文链接:https://www.haomeiwen.com/subject/zsvvhttx.html