The focus animation is a complete custom animation which you have to create by your own. I am currently having exact the same problem like you: I want to show a rectangle as a feedback for the user after he tapped the preview layer.
The first thing you want to do is implementing the tap-to-focus, probably where you initiate the preview layer:
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToFocus:)];
[tapGR setNumberOfTapsRequired:1];
[tapGR setNumberOfTouchesRequired:1];
[self.captureVideoPreviewView addGestureRecognizer:tapGR];
Now implement the tap-to-focus method itself:
-(void)tapToFocus:(UITapGestureRecognizer *)singleTap{
CGPoint touchPoint = [singleTap locationInView:self.captureVideoPreviewView];
CGPoint convertedPoint = [self.captureVideoPreviewLayer captureDevicePointOfInterestForPoint:touchPoint];
AVCaptureDevice *currentDevice = currentInput.device;
if([currentDevice isFocusPointOfInterestSupported] && [currentDevice isFocusModeSupported:AVCaptureFocusModeAutoFocus]){
NSError *error = nil;
[currentDevice lockForConfiguration:&error];
if(!error){
[currentDevice setFocusPointOfInterest:convertedPoint];
[currentDevice setFocusMode:AVCaptureFocusModeAutoFocus];
[currentDevice unlockForConfiguration];
}
}
}
The last thing, which i haven't implemented by myself yet, is to add the focusing animation to the preview layer or rather the view controller which is holding the preview layer. I believe that could be done in tapToFocus:. There you already have the touch point. Simply add a animated image view or some other view which has the touch position as its center. After the animation has finished, remove the image view.