All Products
Search
Document Center

QR code component

Last Updated: May 25, 2021

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

API description

 
  1. // The data model object.
  2. @interface QRDataModel : NSObject
  3. @property (nonatomic, strong) id topLeftIcon; // An image, a URL, or cloudID can be imported.
  4. @property (nonatomic, strong) NSString *topTitle; // An image, a URL, or cloudID can be imported.
  5. @property (nonatomic, strong) id qrCodeIcon; // The QR code image.
  6. @property (nonatomic, strong) NSString *bottomTitle;
  7. @property (nonatomic, strong) NSString *bottomMessage;
  8. @property (nonatomic, strong) id actionButtonIcon; // An image, a URL, or cloudID can be imported.
  9. @property (nonatomic, strong) NSString *actionButtonTitle; // The primary description of the action button at the bottom.
  10. @property (nonatomic, strong) NSString *actionButtonMessage; // The secondary description of the action button at the bottom.
  11. @end
  12. // The action button under the QR code.
  13. @interface QRActionButton : UIControl
  14. @end
  15. // The QR code component.
  16. @interface AUQRCodeView : UIView
  17. @property (nonatomic, strong) UIView *maskView;
  18. @property (nonatomic, strong) UIView *containerView; // The QR code container.
  19. @property (nonatomic, strong) UIImageView *topLeftImageView; // The image in the upper left corner.
  20. @property (nonatomic, strong) UILabel *topTitleLabel; // Description text for the title on the top.
  21. @property (nonatomic, strong) UIImageView *qrCodeView; // The QR code image.
  22. @property (nonatomic, strong) UILabel *bottomTitleLabel; // Main description text at the bottom.
  23. @property (nonatomic, strong) UILabel *bottomMessageLabel; // Secondary description text at the bottom.
  24. @property (nonatomic, strong) QRActionButton *actionButton; // The action button at the bottom.
  25. // The control frame used to block the initialization data model.
  26. - (instancetype)initWithFrame:(CGRect)frame model:(void(^)(QRDataModel *model))block;
  27. // Start loading.
  28. - (void)startLoading;
  29. // Stop loading.
  30. - (void)stopLoading;
  31. @end

Code sample

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

 
  1. AUQRCodeView *qrCodeView = [[AUQRCodeView alloc] initWithFrame:frame model:^(QRDataModel *model) {
  2. model.topLeftIcon = [UIImage imageWithColor:[UIColor colorWithRGB:0xbbbbbb] size:CGSizeMake(54, 54)];
  3. model.topTitle = @"生活号名称";
  4. model.bottomTitle = @"用支付宝二维码,关注生活号";
  5. model.bottomMessage = @"该二维码将在 2017 年 11 月 05 日失效";
  6. model.actionButtonTitle = @"保存到本地";
  7. }];
  8. [self.view addSubview:qrCodeView];