I’m making an attempt to exchange the firstLayer with digital camera preview layer however it doesn’t present up something
The simulator with white display screen seems.
(void) setUpGreyLayer {
// TODO : This layer can be changed with digital camera preview layer
self.firstLayer = [CALayer layer];
self.firstLayer.body = [UIScreen mainScreen].bounds;
self.firstLayer.backgroundColor = [UIColor whiteColor].CGColor;
//Including the greyLayer on prime of firstLayer
self.greyLayer = [CALayer layer];
self.greyLayer.body = self.firstLayer.bounds;
self.greyLayer.backgroundColor = [UIColor grayColor].CGColor;
self.greyLayer.opacity = 0.5;
// Create a masks layer with a transparent rounded rectangle form within the middle
self.maskLayer = [CAShapeLayer layer];
CGRect maskRect = CGRectMake((CGRectGetWidth(self.greyLayer.bounds) - 200) / 2.0, (CGRectGetHeight(self.greyLayer.bounds) - 250) / 2.0 - 0.10 * CGRectGetHeight(self.greyLayer.bounds), 200, 250);
CGFloat cornerRadius = 77.0;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:maskRect cornerRadius:cornerRadius];
[maskPath appendPath:[UIBezierPath bezierPathWithRect:self.greyLayer.bounds].bezierPathByReversingPath];
self.maskLayer.path = maskPath.CGPath;
// Set the masks layer to the greyLayer
self.greyLayer.masks = self.maskLayer;
[self.view.layer addSublayer:self.firstLayer];
[self.view.layer addSublayer:self.greyLayer];
[self setUpCaptureButton];
}
Now my subsequent plan of motion was to exchange the firstlayer with the digital camera preview layer.
However when i added the digital camera preview layer, the simulator solely reveals a clean white display screen with no overlay andthe captured button
is there any particular property of preview_layer, which must be marked checked/unchecked forthe gray overlay to seem on prime of tha
I’m making an attempt to exchange the firstLayer with digital camera preview layer however it doesn’t present up something
The simulator with white display screen seems.
I’m making an attempt to exchange the firstLayer with digital camera preview layer however it doesn’t present up something
The simulator with white display screen seems.
- (void) viewDidLoad {
[super viewDidLoad];
[self setUpGreyLayer];
[self setUpCaptureSession];
[self setUpPreviewLayer];
[self setUpCaptureButton];
}
- (void)setUpPreviewLayer {
self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.captureSession];
self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
self.previewLayer.body = self.view.bounds;
[self.view.layer addSublayer:self.previewLayer];
}
(void) setUpGreyLayer {
// TODO : This layer can be changed with digital camera preview layer
>! self.firstLayer = [CALayer layer];
>! self.firstLayer.body = [UIScreen mainScreen].bounds;
>! self.firstLayer.backgroundColor = [UIColor whiteColor].CGColor;
//Including the greyLayer on prime of previewLayer
self.greyLayer = [CALayer layer];
self.greyLayer.body = self.previewLayer.bounds;
self.greyLayer.backgroundColor = [UIColor grayColor].CGColor;
self.greyLayer.opacity = 0.5;
// Create a masks layer with a transparent rounded rectangle form within the middle
self.maskLayer = [CAShapeLayer layer];
CGRect maskRect = CGRectMake((CGRectGetWidth(self.greyLayer.bounds) - 200) / 2.0, (CGRectGetHeight(self.greyLayer.bounds) - 250) / 2.0 - 0.10 * CGRectGetHeight(self.greyLayer.bounds), 200, 250);
CGFloat cornerRadius = 77.0;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:maskRect cornerRadius:cornerRadius];
[maskPath appendPath:[UIBezierPath bezierPathWithRect:self.greyLayer.bounds].bezierPathByReversingPath];
self.maskLayer.path = maskPath.CGPath;
// Set the masks layer to the greyLayer
self.greyLayer.masks = self.maskLayer;
>! [self.view.layer addSublayer:self.firstLayer];
[self.view.layer addSublayer:self.greyLayer];
[self setUpCaptureButton];
}