美文网首页
生成二维码

生成二维码

作者: 薰衣草儿 | 来源:发表于2017-01-17 13:37 被阅读49次

    前几天写了一个怎么获取app连接,并且通过程序调转到appstrore的文章,但是呢,有很多并不单单的在项目中去跳转,而且还需要生成一个二维码,然后直接去appstore下载,在这里 ,我就来写一下怎么生成二维码,非常简单:

    //点击按钮 出现二维码

    @interface ViewController ()

    @property (nonatomic,strong)UIImageView *QRCodeImgView; //二维码view

    @end

    @implementation ViewController

    - (void)viewDidLoad {

    [super viewDidLoad];

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

    btn.frame = CGRectMake(20, 50,200, 50);

    btn.backgroundColor = [UIColor yellowColor];

    [btn setTitle:@"点击出现二维码" forState:UIControlStateNormal];

    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:btn];

    }

    - (void)btnClick:(UIButton *)btn{

    btn.enabled = NO;

    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];

    imgView.center = self.view.center;

    imgView.backgroundColor = [UIColor whiteColor];

    self.QRCodeImgView = imgView;

    [self.view addSubview:imgView];

    //获取内置滤镜的种类

    NSLog(@"内置滤镜的种类 %@",[CIFilter filterNamesInCategory:kCICategoryBuiltIn]);

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

    //设置默认值

    [filter setDefaults];

    NSLog(@"inputKey %@",filter.inputKeys);

    //封装数据 字符串

    [filter setValue:[@"itunes.apple.com/us/app/zhi-fu-bao-rang-sheng-huo/id333206289?mt=8" dataUsingEncoding:NSUTF8StringEncoding] forKey:@"inputMessage"];

    //放大原图

    CIImage *resultImage = [filter.outputImage imageByApplyingTransform:CGAffineTransformMakeScale(5, 5)];

    self.QRCodeImgView.image  = [UIImage imageWithCIImage:resultImage];

    }

    其实这些代码就可以了 还是以上篇文章的支付宝的连接为例子来写的  主要是很多人分不清kCICategoryBuiltIn 的种类那么多 都是什么意思呢 ?那么这里我就跟大家说一些常用的

    内置滤镜的种类 (

    CIAdditionCompositing, //影像合成\

    CICheckerboardGenerator, //棋盘发生器

    CIColorBlendMode,  //CIColor的混合模式

    CIColorBurnBlendMode, //CIColor的燃烧混合模式

    CIColorCube,  //立方体

    CIColorDodgeBlendMode,  //CIColor的避免混合模式

    CIColorInvert, //CIColor 相反

    CIColorMatrix, //CIColor 矩阵

    CIColorMonochrome,  //黑白照

    CIConstantColorGenerator, //恒定颜色发生器

    CICrop,        //裁剪

    CIDarkenBlendMode,  //亮度混合模式

    CIDifferenceBlendMode,  //差分混合模式

    CIExclusionBlendMode,  //互斥混合模式

    CIExposureAdjust, //曝光调节

    CIFalseColor,    //伪造颜色

    CIGammaAdjust,  //灰色系数调节

    CIGaussianBlur,    //高斯模糊效果

    CIGaussianGradient,  //高斯梯度

    CIHardLightBlendMode,  //强光混合模式

    CIHighlightShadowAdjust,  //高亮阴影调节

    CIHueAdjust,  //饱和度调节

    CIHueBlendMode, //饱和度混合模式

    CILinearGradient,  //线性梯度

    CILuminosityBlendMode,  //亮度混合模式

    CIMaximumCompositing,  //最大合成

    CIMinimumCompositing,  //最小合成

    CIMultiplyBlendMode,  //多层次混合模式

    CIMultiplyCompositing,  //多层合成

    CIOverlayBlendMode,  //覆盖叠加混合模式

    CIPhotoEffectTransfer,

    CIPinchDistortion,

    CIPinLightBlendMode,

    CIPixellate,

    CIPointillize,

    CIQRCodeGenerator,

    CIRadialGradient,  //半径梯度

    CIRandomGenerator,

    CIRippleTransition,

    CIRowAverage,

    CISaturationBlendMode, //饱和度混合模式

    CIScreenBlendMode,  //全屏混合模式

    CISepiaTone,      //棕黑色调

    CIShadedMaterial,

    CISharpenLuminance,

    CISixfoldReflectedTile,

    CISixfoldRotatedTile,

    CISmoothLinearGradient,

    CISoftLightBlendMode,  //软光混合模式

    CISourceAtopCompositing,

    CISourceInCompositing,

    CISourceOutCompositing,

    CISourceOverCompositing,

    CISpotColor,

    CISpotLight,

    CISRGBToneCurveToLinear,

    CIStarShineGenerator,

    CIStraightenFilter,  //拉直过滤器

    CIStretchCrop,

    CIStripesGenerator,  //条纹发生器

    CISubtractBlendMode,

    CISunbeamsGenerator,

    CISwipeTransition,

    CITemperatureAndTint,  //色温

    CIThermal,

    CIToneCurve,      //色调曲线

    CITorusLensDistortion,

    CITriangleKaleidoscope,

    CITriangleTile,

    CITwelvefoldReflectedTile,

    CITwirlDistortion,

    CIUnsharpMask,

    CIVibrance,  //震动

    CIVignette,  //印花

    CIVignetteEffect,

    CIVortexDistortion,

    CIWhitePointAdjust,  //白平衡调节

    希望通过这篇文章对大家哪怕有那么一点的帮助😊

    demo:http://www.jianshu.com/writer#/notebooks/8035700/notes/8516833

    相关文章

      网友评论

          本文标题:生成二维码

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