2015-07-27 16:08:33 +06:00
|
|
|
#import "CameraFocusSquare.h"
|
|
|
|
#import <QuartzCore/QuartzCore.h>
|
|
|
|
|
|
|
|
const float squareLength = 80.0f;
|
|
|
|
@implementation RCTCameraFocusSquare
|
|
|
|
|
|
|
|
- (id)initWithFrame:(CGRect)frame
|
|
|
|
{
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
if (self) {
|
|
|
|
// Initialization code
|
|
|
|
|
|
|
|
[self setBackgroundColor:[UIColor clearColor]];
|
2017-10-16 17:06:26 +02:00
|
|
|
[self.layer setBorderWidth:1.0];
|
2015-07-27 16:08:33 +06:00
|
|
|
[self.layer setBorderColor:[UIColor whiteColor].CGColor];
|
2017-10-16 17:06:26 +02:00
|
|
|
|
|
|
|
CGSize size = frame.size;
|
|
|
|
CGRect rect = CGRectMake(0, 0, size.width, size.height);
|
|
|
|
|
|
|
|
UIBezierPath *endPath = [UIBezierPath bezierPath];
|
|
|
|
[endPath moveToPoint:CGPointMake(CGRectGetMinX(rect) + size.width / 2.0, CGRectGetMinY(rect))];
|
|
|
|
[endPath addLineToPoint:CGPointMake(CGRectGetMinX(rect) + size.width / 2.0, CGRectGetMinY(rect) + 5.0)];
|
|
|
|
[endPath moveToPoint:CGPointMake(CGRectGetMaxX(rect), CGRectGetMinY(rect) + size.height / 2.0)];
|
|
|
|
[endPath addLineToPoint:CGPointMake(CGRectGetMaxX(rect) - 5.0, CGRectGetMinY(rect) + size.height / 2.0)];
|
|
|
|
|
|
|
|
[endPath moveToPoint:CGPointMake(CGRectGetMinX(rect) + size.width / 2.0, CGRectGetMaxY(rect))];
|
|
|
|
[endPath addLineToPoint:CGPointMake(CGRectGetMinX(rect) + size.width / 2.0, CGRectGetMaxY(rect) - 5.0)];
|
|
|
|
[endPath moveToPoint:CGPointMake(CGRectGetMinX(rect), CGRectGetMinY(rect) + size.height / 2.0)];
|
|
|
|
[endPath addLineToPoint:CGPointMake(CGRectGetMinX(rect) + 5.0, CGRectGetMinY(rect) + size.height / 2.0)];
|
2015-07-27 16:08:33 +06:00
|
|
|
|
2017-10-16 17:06:26 +02:00
|
|
|
CAShapeLayer *extraLayer = [CAShapeLayer layer];
|
|
|
|
extraLayer.path = endPath.CGPath;
|
|
|
|
extraLayer.fillColor = [UIColor clearColor].CGColor;
|
|
|
|
extraLayer.strokeColor = [UIColor colorWithRed:1.0 green:0.83 blue:0 alpha:0.95].CGColor;
|
|
|
|
extraLayer.lineWidth = 1.0;
|
|
|
|
[self.layer addSublayer:extraLayer];
|
|
|
|
|
2015-07-27 16:08:33 +06:00
|
|
|
CABasicAnimation* selectionAnimation = [CABasicAnimation
|
|
|
|
animationWithKeyPath:@"borderColor"];
|
2017-10-16 17:06:26 +02:00
|
|
|
selectionAnimation.toValue = (id)[UIColor colorWithRed:1.0 green:0.83 blue:0 alpha:0.95].CGColor;
|
2015-07-27 16:08:33 +06:00
|
|
|
selectionAnimation.repeatCount = 8;
|
|
|
|
[self.layer addAnimation:selectionAnimation
|
|
|
|
forKey:@"selectionAnimation"];
|
|
|
|
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
2017-10-16 17:06:26 +02:00
|
|
|
@end
|