All Products
Search
Document Center

QR code component

Last Updated: Feb 24, 2022

AUQRCodeView is the Alert view that supports multiple option buttons. The Window level of QR code component follows the logic self.windowLevel = UIWindowLevelAlert - 1.

Sample image

QR code2

API description

// The data model object.
@interface QRDataModel : NSObject

@property (nonatomic, strong) id topLeftIcon;                // An image, a URL, or cloudID can be imported.
@property (nonatomic, strong) NSString *topTitle;            // An image, a URL, or cloudID can be imported.
@property (nonatomic, strong) id qrCodeIcon;                 // The QR code image.
@property (nonatomic, strong) NSString *bottomTitle;
@property (nonatomic, strong) NSString *bottomMessage;
@property (nonatomic, strong) id actionButtonIcon;           // An image, a URL, or cloudID can be imported.
@property (nonatomic, strong) NSString *actionButtonTitle;   // The primary description of the action button at the bottom.
@property (nonatomic, strong) NSString *actionButtonMessage; // The secondary description of the action button at the bottom.

@end

// The action button under the QR code.
@interface QRActionButton : UIControl

@end


// The QR code component.
@interface AUQRCodeView : UIView

@property (nonatomic, strong) UIView *maskView;
@property (nonatomic, strong) UIView *containerView;          // The QR code container.
@property (nonatomic, strong) UIImageView *topLeftImageView;  // The image in the upper left corner.
@property (nonatomic, strong) UILabel *topTitleLabel;         // Description text for the title on the top.
@property (nonatomic, strong) UIImageView *qrCodeView;        // The QR code image.
@property (nonatomic, strong) UILabel *bottomTitleLabel;      // Main description text at the bottom.
@property (nonatomic, strong) UILabel *bottomMessageLabel;    // Secondary description text at the bottom.
@property (nonatomic, strong) QRActionButton *actionButton;   // The action button at the bottom.

// The control frame used to block the initialization data model.
- (instancetype)initWithFrame:(CGRect)frame model:(void(^)(QRDataModel *model))block;

// Start loading.
- (void)startLoading;

// Stop loading.
- (void)stopLoading;

@end

Code sample

The following sample shows the code of a standard style QR code.

    AUQRCodeView *qrCodeView = [[AUQRCodeView alloc] initWithFrame:frame model:^(QRDataModel *model) {
        model.topLeftIcon = [UIImage imageWithColor:[UIColor colorWithRGB:0xbbbbbb] size:CGSizeMake(54, 54)];
        model.topTitle = @"Alipay life account";
        model.bottomTitle = @"Scan this QR code to follow";
        model.bottomMessage = @"This QR code will expire on November 05, 2017";
        model.actionButtonTitle = @"Save locally";
    }];
    [self.view addSubview:qrCodeView];