From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001 From: 单军华 Date: Wed, 11 Jul 2018 10:47:42 +0800 Subject: [PATCH] 首次上传 --- screendisplay/Pods/HMQRCodeScanner/HMQRCodeScanner/QRCode/HMScannerBorder.m | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-) diff --git a/screendisplay/Pods/HMQRCodeScanner/HMQRCodeScanner/QRCode/HMScannerBorder.m b/screendisplay/Pods/HMQRCodeScanner/HMQRCodeScanner/QRCode/HMScannerBorder.m new file mode 100755 index 0000000..4303968 --- /dev/null +++ b/screendisplay/Pods/HMQRCodeScanner/HMQRCodeScanner/QRCode/HMScannerBorder.m @@ -0,0 +1,96 @@ +// +// HMScannerBorder.m +// HMQRCodeScanner +// +// Created by ������ on 16/1/2. +// Copyright �� 2016��� itheima. All rights reserved. +// + +#import "HMScannerBorder.h" + +@implementation HMScannerBorder { + /// ��������������� + UIImageView *scannerLine; +} + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self prepareUI]; + } + return self; +} + +#pragma mark - ������������������ +/// ������������������ +- (void)startScannerAnimating { + + [self stopScannerAnimating]; + + [UIView animateWithDuration:3.0 + delay:0.0 + options:UIViewAnimationOptionCurveEaseInOut + animations:^{ + [UIView setAnimationRepeatCount:MAXFLOAT]; + + scannerLine.center = CGPointMake(self.bounds.size.width * 0.5, self.bounds.size.height); + } completion:nil]; +} + +/// ������������������ +- (void)stopScannerAnimating { + [scannerLine.layer removeAllAnimations]; + scannerLine.center = CGPointMake(self.bounds.size.width * 0.5, 0); +} + +#pragma mark - ������������ +- (void)prepareUI { + self.clipsToBounds = YES; + + // ��������������� + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSURL *url = [bundle URLForResource:@"HMScanner" withExtension:@"bundle"]; + NSBundle *imageBundle = [NSBundle bundleWithURL:url]; + + // ��������������� + scannerLine = [[UIImageView alloc] initWithImage:[self imageWithName:@"QRCodeScanLine" bundle:imageBundle]]; + + scannerLine.frame = CGRectMake(0, 0, self.bounds.size.width, scannerLine.bounds.size.height); + scannerLine.center = CGPointMake(self.bounds.size.width * 0.5, 0); + + [self addSubview:scannerLine]; + + // ������������������ + for (NSInteger i = 1; i < 5; i++) { + NSString *imgName = [NSString stringWithFormat:@"ScanQR%zd", i]; + UIImageView *img = [[UIImageView alloc] initWithImage:[self imageWithName:imgName bundle:imageBundle]]; + + [self addSubview:img]; + + CGFloat offsetX = self.bounds.size.width - img.bounds.size.width; + CGFloat offsetY = self.bounds.size.height - img.bounds.size.height; + + switch (i) { + case 2: + img.frame = CGRectOffset(img.frame, offsetX, 0); + break; + case 3: + img.frame = CGRectOffset(img.frame, 0, offsetY); + break; + case 4: + img.frame = CGRectOffset(img.frame, offsetX, offsetY); + break; + default: + break; + } + } +} + +- (UIImage *)imageWithName:(NSString *)imageName bundle:(NSBundle *)imageBundle { + NSString *fileName = [NSString stringWithFormat:@"%@@2x", imageName]; + NSString *path = [imageBundle pathForResource:fileName ofType:@"png"]; + + return [[UIImage imageWithContentsOfFile:path] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; +} + +@end -- Gitblit v1.8.0