FWQrcodeScanManager


@interface FWQrcodeScanManager : NSObject

FWQrcodeScanManager

Scan

  • 会话预置,默认为:AVCaptureSessionPreset1920x1080

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nonnull sessionPreset;
  • 元对象类型,默认为:AVMetadataObjectTypeQRCode

    Declaration

    Objective-C

    @property (nonatomic, strong) NSArray *_Nonnull metadataObjectTypes;
  • 扫描范围,默认整个视图(每一个取值 0 ~ 1,以屏幕右上角为坐标原点)

    Declaration

    Objective-C

    @property (nonatomic) CGRect rectOfInterest;
  • 是否需要样本缓冲代理(光线强弱),默认为:NO

    Declaration

    Objective-C

    @property (nonatomic) BOOL sampleBufferDelegate;
  • 扫描二维码回调方法

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^) (NSString *_Nullable __strong) scanResultBlock;
  • 扫描二维码光线强弱回调方法;调用之前配置属性 sampleBufferDelegate 必须为 YES

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^)(CGFloat) scanBrightnessBlock;
  • 创建扫描二维码方法

    Declaration

    Objective-C

    - (void)scanQrcodeWithView:(nonnull UIView *)view;
  • 开启扫描回调方法

    Declaration

    Objective-C

    - (void)startRunning;
  • 停止扫描方法

    Declaration

    Objective-C

    - (void)stopRunning;
  • 打开手电筒

    Declaration

    Objective-C

    + (void)openFlashlight;
  • 关闭手电筒

    Declaration

    Objective-C

    + (void)closeFlashlight;
  • 配置扫描设备,比如自动聚焦等

    Declaration

    Objective-C

    + (void)configCaptureDevice:
        (nonnull void (^)(AVCaptureDevice *_Nonnull __strong))block;

Image

  • Undocumented

    Declaration

    Objective-C

    + (nullable NSString *)scanQrcodeWithImage:(UIImage *)image;

Generate

  • 生成二维码

    Declaration

    Objective-C

    + (nonnull UIImage *)generateQrcodeWithData:(nonnull NSString *)data
                                           size:(CGFloat)size;

    Parameters

    data

    二维码数据

    size

    二维码大小

  • 生成二维码(自定义颜色)

    Declaration

    Objective-C

    + (nonnull UIImage *)generateQrcodeWithData:(nonnull NSString *)data
                                           size:(CGFloat)size
                                          color:(nonnull UIColor *)color
                                backgroundColor:(nonnull UIColor *)backgroundColor;

    Parameters

    data

    二维码数据

    size

    二维码大小

    color

    二维码颜色

    backgroundColor

    二维码背景颜色

  • 生成带 logo 的二维码(推荐使用)

    Declaration

    Objective-C

    + (nonnull UIImage *)generateQrcodeWithData:(nonnull NSString *)data
                                           size:(CGFloat)size
                                      logoImage:(nullable UIImage *)logoImage
                                          ratio:(CGFloat)ratio;

    Parameters

    data

    二维码数据

    size

    二维码大小

    logoImage

    logo

    ratio

    logo 相对二维码的比例(取值范围 0.0 ~ 0.5f)

  • 生成带 logo 的二维码(拓展)

    Declaration

    Objective-C

    + (nonnull UIImage *)generateQrcodeWithData:(nonnull NSString *)data
                                           size:(CGFloat)size
                                      logoImage:(nullable UIImage *)logoImage
                                          ratio:(CGFloat)ratio
                          logoImageCornerRadius:(CGFloat)logoImageCornerRadius
                           logoImageBorderWidth:(CGFloat)logoImageBorderWidth
                           logoImageBorderColor:
                               (nullable UIColor *)logoImageBorderColor;

    Parameters

    data

    二维码数据

    size

    二维码大小

    logoImage

    logo

    ratio

    logo 相对二维码的比例(取值范围 0.0 ~ 0.5f)

    logoImageCornerRadius

    logo 外边框圆角(取值范围 0.0 ~ 10.0f)

    logoImageBorderWidth

    logo 外边框宽度(取值范围 0.0 ~ 10.0f)

    logoImageBorderColor

    logo 外边框颜色